public static interface Widget.MotionNotifyEvent
Note that by default this event is disabled, even if you connect to it.
You will need to enable
it. If you
want to receive all mouse motion events, you will need to supply the
POINTER_MOTION mask. Note that it generates a big amount of events,
typically tens of events per second, when the user moves the mouse over
this Widget. If you only care about this event when a mouse button is
pressed, any of LEFT_BUTTON_MOTION, MIDDLE_BUTTON_MOTION,
RIGHT_BUTTON_MOTION or BUTTON_MOTION masks can be used instead.
Many times, however, you are only interested on this events in some specific circunstances. For example, a drawing application may be interested on this when the user has selected a drawing tool (e.g. a pencil) and is actually drawing (e.g. by clicking the mouse). In such cases, enabling the event when needed, and disabling it when no more needed, is the best alternative. For example:
// hook up a handler to mouse button event. drawarea.connect(new Widget.MotionNotifyEvent() { public boolean onMotionNotifyEvent(Widget source, EventMotion event) { double x, y; x = event.getX(); y = event.getY(); // draw something, x and y hold the mouse position } });
Modifier and Type | Method and Description |
---|---|
boolean |
onMotionNotifyEvent(Widget source,
EventMotion event) |
boolean onMotionNotifyEvent(Widget source, EventMotion event)