简体   繁体   English

当鼠标离开时,SWT MouseMove侦听器

[英]SWT MouseMove Listener when mouse is… out

I use a mouse move listener to handle mouse moves on a canvas in SWT. 我使用鼠标移动侦听器来处理SWT中画布上的鼠标移动。 But I'd like to have two behaviours, one when the mouse is moving into the canvas area and another one when the mouse is quiting the area. 但是我想有两种行为,一种是鼠标移入画布区域时,另一种是鼠标退出画布区域时。

In fact what I really like to do is to change the cursor icon when the mouse is in the area and restore it when it is out. 实际上,我真正想做的就是在鼠标位于该区域时更改光标图标,并在鼠标移出该区域时恢复它。 But I can only capture events when the mouse is in the area. 但我只能在鼠标位于该区域时捕获事件。

Is there a specific listener to handle the Mouse Out event on a Canvas? 是否有特定的侦听器来处理Canvas上的Mouse Out事件?

Thank you. 谢谢。

You are looking for a MouseTrackListener, it has methods for entering, exiting and hovering an element. 您正在寻找一个MouseTrackListener,它具有用于输入,退出和悬停元素的方法。 See http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/events/MouseTrackListener.html 请参阅http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/events/MouseTrackListener.html

This is what you're looking for: 这是您要寻找的:

public void mouseExited(MouseEvent e) {
   saySomething("Mouse exited", e);
}

Follow this link: 点击此链接:

Oracle MouseListeners Oracle MouseListeners

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM