查看DomainEventDispatcher的源代码
/**
* @see EventDispatcher#dispatchMouseMoved(org.eclipse.swt.events.MouseEvent)
*/
public void dispatchMouseMoved(org.eclipse.swt.events.MouseEvent me) {
if (!editorCaptured) {
super.dispatchMouseMoved(me);
if (draw2dBusy())
return;
}
//在GEF中,区分mouse move和mouse drag,在mouse move的同时,假如按下了鼠标键,就会当作是mouse drag去处理了
if (okToDispatch()) {
if ((me.stateMask & InputEvent.ANY_BUTTON) != 0)
domain.mouseDrag(me, viewer);
else
domain.mouseMove(me, viewer);
}
}
/**
* @see EventDispatcher#dispatchMouseMoved(org.eclipse.swt.events.MouseEvent)
*/
public void dispatchMouseMoved(org.eclipse.swt.events.MouseEvent me) {
if (!editorCaptured) {
super.dispatchMouseMoved(me);
if (draw2dBusy())
return;
}
//在GEF中,区分mouse move和mouse drag,在mouse move的同时,假如按下了鼠标键,就会当作是mouse drag去处理了
if (okToDispatch()) {
if ((me.stateMask & InputEvent.ANY_BUTTON) != 0)
domain.mouseDrag(me, viewer);
else
domain.mouseMove(me, viewer);
}
}
我们还可以查看Tool源代码中的说明:
/**
* Called when a Viewer receives a mouse drag. SWT does not distinguish(区分) between mouse
* drags and mouse moves, but GEF Viewers will make this distinction when dispatching
* events. A drag occurs if any mouse button is down.
* @param mouseEvent the SWT mouse event
* @param viewer the Viewer which received a drag
* SWT并不区分mouse drag和mouse move,在gef中,在mouse move的过程中,按下任意的鼠标键的同时,就代表mouse drag事件
*/
void mouseDrag(MouseEvent mouseEvent, EditPartViewer viewer);