163 |
currentDrag = null; |
currentDrag = null; |
164 |
} |
} |
165 |
|
|
166 |
|
/** Whether a drag from a mouse press and a |
167 |
|
* subsequent mouse motion event has been started. |
168 |
|
* It is extremely not allowed to call the |
169 |
|
* endDrag() method if there were no drag events, |
170 |
|
* otherwise clicked and endDrag methods |
171 |
|
* are probably both called. |
172 |
|
*/ |
173 |
|
private boolean dragStarted = false; |
174 |
|
|
175 |
/** Send an event to the correct listener. |
/** Send an event to the correct listener. |
176 |
* @return true if the event was used by this multiplexer. |
* @return true if the event was used by this multiplexer. |
183 |
if(mpl == null) return false; |
if(mpl == null) return false; |
184 |
currentDrag = mpl.pressed(e.getX(), e.getY()); |
currentDrag = mpl.pressed(e.getX(), e.getY()); |
185 |
if(currentDrag != null) { |
if(currentDrag != null) { |
186 |
|
dragStarted = false; |
187 |
currentDragButton = e.getButton(); |
currentDragButton = e.getButton(); |
188 |
currentDrag.startDrag(e.getX(), e.getY()); |
currentDrag.startDrag(e.getX(), e.getY()); |
189 |
return true; |
return true; |
190 |
} |
} |
191 |
} else if(e.getType() == e.MOUSE_DRAGGED) { |
} else if(e.getType() == e.MOUSE_DRAGGED) { |
192 |
if(currentDrag != null) { |
if(currentDrag != null) { |
193 |
|
dragStarted = true; |
194 |
currentDrag.drag(e.getX(), e.getY()); |
currentDrag.drag(e.getX(), e.getY()); |
195 |
return true; |
return true; |
196 |
} |
} |
198 |
if(currentDragButton != 0 && |
if(currentDragButton != 0 && |
199 |
e.getButton() == currentDragButton) { |
e.getButton() == currentDragButton) { |
200 |
currentDragButton = 0; |
currentDragButton = 0; |
201 |
currentDrag.endDrag(e.getX(), e.getY()); |
if (dragStarted) |
202 |
|
currentDrag.endDrag(e.getX(), e.getY()); |
203 |
currentDrag = null; |
currentDrag = null; |
204 |
return true; |
return true; |
205 |
} |
} |