public class PointerEventDispatcher extends EventDispatcher
Pointer events are grouped in sessions. A session starts when the pointer is pressed, and ends when the pointer is released or when it exits the pressed widget.
While no widget consumes the events, they are sent to the widget that is under the pointer (see
Desktop.getWidgetAt(int, int)
), then sent to all its parent hierarchy.
Once a widget has consumed an event, it will be the only one to receive the next events during the session.
Modifier and Type | Field and Description |
---|---|
static int |
EXITED
The "exited" action.
|
Constructor and Description |
---|
PointerEventDispatcher(Desktop desktop)
Creates a desktop event dispatcher.
|
Modifier and Type | Method and Description |
---|---|
protected DesktopEventGenerator |
createEventGenerator()
Creates the event generator which is responsible for generating exit events to the widgets.
|
boolean |
dispatchEvent(int event)
Dispatches an event.
|
void |
dispose()
Disposes this event dispatcher.
|
Widget |
getConsumerWidget()
Returns the widget which has consumed the ongoing pointer session.
|
protected DesktopEventGenerator |
getEventGenerator()
Gets the event generator of this dispatcher.
|
Widget |
getPressedHierarchyLeaf()
Returns the leaf widget of the hierarchy which is subscribed to the ongoing pointer session.
|
void |
initialize()
Initializes this event dispatcher.
|
static boolean |
isExited(int event)
Returns whether or not the given event is an exited event.
|
getDesktop, sendEventToWidget, sendEventToWidgetHierarchy
public static final int EXITED
public PointerEventDispatcher(Desktop desktop)
desktop
- the desktop to dispatch in.protected DesktopEventGenerator createEventGenerator()
desktop event generator
is created.DesktopEventGenerator
public boolean dispatchEvent(int event)
EventDispatcher
dispatchEvent
in class EventDispatcher
event
- the event to dispatch.true
if the event dispatcher has dealt with the event, false
otherwise.public void dispose()
EventDispatcher
After this call, all that has been allocated or started in the EventDispatcher.initialize()
method must be disposed or
stopped.
dispose
in class EventDispatcher
@Nullable public Widget getConsumerWidget()
When a pointer event is been consumed during a pointer session, it becomes the only widget to be subscribed to this session.
The reference to this widget is initialized when a pointer event is consumed ; and it is reset when the pointer is released or when the pointer is dragged outside of the bounds of the widget.
null
if there is none.@Nullable protected DesktopEventGenerator getEventGenerator()
@Nullable public Widget getPressedHierarchyLeaf()
When a pointer session is started, all the enabled widgets under the pointer become subscribed to this session.
The reference to this widget is initialized when the pointer is pressed ; it is updated when the pointer is dragged outside of the bounds of the widget or when a pointer event is consumed ; and it is reset when the pointer is released or when the pointer is dragged outside of the bounds of each subscribed widgets.
null
if there is none.public void initialize()
EventDispatcher
For example, this method can be used to create an event generator.
initialize
in class EventDispatcher
public static final boolean isExited(int event)
event
- the event to check.