4
|
1 module user.doob_test1.MouseHandler;
|
|
2
|
|
3 private import dwt.events.MouseListener;
|
|
4 private import dwt.events.MouseMoveListener;
|
|
5 private import dwt.events.MouseEvent;
|
|
6
|
|
7 private import tango.io.Stdout;
|
|
8
|
|
9 private import user.doob_test1.PaintHandler;
|
|
10
|
|
11 class MouseHandler : MouseListener, MouseMoveListener {
|
|
12 PaintHandler hPaint;
|
|
13 bool pressed = false;
|
|
14
|
|
15 this(PaintHandler ph) {
|
|
16 hPaint = ph;
|
|
17 }
|
|
18
|
|
19 void mouseDoubleClick(MouseEvent e) {
|
|
20 }
|
|
21
|
|
22 void mouseDown(MouseEvent e) {
|
|
23 hPaint.x = e.x;
|
|
24 hPaint.y = e.y;
|
|
25 pressed = true;
|
|
26 }
|
|
27
|
|
28 void mouseUp(MouseEvent e) {
|
|
29 hPaint.xDiff = e.x-hPaint.x;
|
|
30 hPaint.yDiff = e.y-hPaint.y;
|
|
31 hPaint.reDraw();
|
|
32 pressed = false;
|
|
33 }
|
|
34
|
|
35 void mouseMove(MouseEvent e) {
|
|
36 if(pressed) {
|
|
37 hPaint.xDiff = e.x-hPaint.x;
|
|
38 hPaint.yDiff = e.y-hPaint.y;
|
|
39 hPaint.reDraw();
|
|
40 }
|
|
41 }
|
|
42 } |