consume
Prevents further processing of this event.
Warning Consuming events should not be done lightly. Are you sure there aren't handlers later in the chain/bubbling process that_need_ to receive the event?
Mouse events go through a 'bubbling' phase. We find the deepest node at the mouse position, and work down the scene graph from the root not to the deepest node, calling event filters
(See Node.addEventFilter). We then work our way up the scene graph, from the deepest node to the root, calling event handlers
(See Node.addEventHandler).
If an event handler/filter consumes the event, then no other handlers/filters receive the event.
Other event types do not have the bubbling
concept. e.g. ButtonBase.onAction, as they delivered to one Node. However, you may still use consume, as ButtonBase.onAction may be a chain of handlers. If one handler in the chain consumes the event, later handlers in the chain will not receive the event.
consume may also have additional semantics for specific events. For example, Stage
and Tab
check isConsumed after a close requested
event, and will refuse to close if the event was consumed.