-
public interface EventDispatcherAnEventDispatcherrepresents an event dispatching and processing entity. It is used when anEventneeds to be dispatched to the associatedEventTargetthrough theEventDispatchChainspecified by the target. EachEventDispatcherin the chain can influence the event path and the event itself. OneEventDispatchercan appear in multiple chains.The system defines two successive phases of event delivery. The first phase is called capturing phase and happens when when an event travels from the first element of the
EventDispatchChainassociated with the event target to its last element. If the event target is part of some hierarchy, the direction of the event in this phase usually corresponds with the direction from the root element of the hierarchy to the target. The second phase is called bubbling phase and happens in the reverse order to the first phase. So the event is returning back from the last element of theEventDispatchChainto its first element in this phase. Usually that corresponds to the direction from the event target back to the root in the event target's hierarchy.Each
EventDispatcherin anEventDispatchChainis responsible for forwarding the event to the rest of the chain during event dispatching. This forwarding happens in thedispatchEventmethod and forms a chain of nested calls which allows oneEventDispatcherto see the event during both dispatching phases in a singledispatchEventcall.Template for
dispatchEventimplementation.public Event dispatchEvent(Event event, EventDispatchChain tail) { // capturing phase, can handle / modify / substitute / divert the event if (notHandledYet) { // forward the event to the rest of the chain event = tail.dispatchEvent(event); if (event != null) { // bubbling phase, can handle / modify / substitute / divert // the event } } return notHandledYet ? event : null;}- Since:
- JavaFX 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description EventdispatchEvent(Event event, EventDispatchChain tail)Dispatches the specified event by thisEventDispatcher.
-
-
-
Method Detail
-
dispatchEvent
Event dispatchEvent(Event event, EventDispatchChain tail)
Dispatches the specified event by thisEventDispatcher. Does any required event processing. Both the event and its further path can be modified in this method. If the event is not handled / consumed during the capturing phase, it should be dispatched to the rest of the chain (event = tail.dispatch(event);).- Parameters:
event- the event do dispatchtail- the rest of the chain to dispatch event to- Returns:
- the return event or
nullif the event has been handled / consumed
-
-