1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.gwt.widget.client;
26
27 import com.google.gwt.user.client.DOM;
28 import com.google.gwt.user.client.ui.PopupPanel;
29 import com.google.gwt.user.client.ui.Widget;
30
31
32
33
34
35
36
37 public class DragListener {
38
39 PopupPanel widgetToMove;
40 boolean isDragged = false;
41 int dragStartX;
42 int dragStartY;
43
44 public DragListener(PopupPanel widgetToMove) {
45 this.widgetToMove = widgetToMove;
46 }
47
48 public void onMouseDown(Widget sender, int x, int y) {
49 isDragged = true;
50 dragStartX = x;
51 dragStartY = y;
52 DOM.setCapture(sender.getElement());
53 }
54
55 public void onMouseMove(Widget sender, int x, int y) {
56 if (isDragged) {
57 widgetToMove.setPopupPosition(widgetToMove.getAbsoluteLeft() + x - dragStartX, widgetToMove.getAbsoluteTop() + y - dragStartY);
58 }
59 }
60
61 public void onMouseUp(Widget sender, int x, int y) {
62 isDragged = false;
63 DOM.releaseCapture(sender.getElement());
64 }
65
66 public void onMouseEnter(Widget sender) {
67
68 }
69
70 public void onMouseLeave(Widget sender) {
71
72 }
73
74 }