GEF中区分mouse move和mouse drag

查看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);
 }
}


我们还可以查看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);

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值