Interface Event
- All Known Subinterfaces:
Cancelable, CharEvent, ControlEvent<C>, DragEvent, FocusEvent, KeyEvent, LifecycleEvent, MeasureEvent, ModifiersEvent, PaintEvent, PaintEvent.Pre, PointerButtonEvent, PointerEvent, RequestEvent<C>, ScrollEvent, SnapshotEvent, TransferEvent, ValueEvent<C,V>, ValueRequestEvent<C, V>
public interface Event
Base of every UI event. See the package description for the order
in which handlers and default behavior run.
An event object is valid only while it is being delivered. Do not keep it and read it later: Strata may reuse
objects or make current() change. To keep the state a component had when the event fired, take its
snapshot from a SnapshotEvent, which stays valid.
Only Strata creates events. Do not implement this interface.
-
Method Summary
Modifier and TypeMethodDescriptioncause()Returns what led to the event: the objects the change passed through and the context, such as who caused it and with which device.Component<?> current()Returns the component whose handlers or default behavior are running now.booleanReturns whether propagation was stopped.origin()Returns who caused the event, without making the whole cause.voidKeeps the event from reaching any further ancestor.Component<?> target()Returns the component the event was fired at.
-
Method Details
-
target
-
current
-
cause
Cause cause()Returns what led to the event: the objects the change passed through and the context, such as who caused it and with which device. Strata makes the cause when this is called, from the frames open at that moment. During delivery those are the frames that were open when the event fired, so call it before opening a frame of your own.- Returns:
- the cause; never null
-
origin
Origin origin()Returns who caused the event, without making the whole cause.- Returns:
- the origin the innermost open frame put, or
Origin.CODEwhen none did
-
stopPropagation
void stopPropagation()Keeps the event from reaching any further ancestor. The current component's remaining handlers and default behavior still run. Works on every event, including those that cannot be canceled. -
isPropagationStopped
boolean isPropagationStopped()Returns whether propagation was stopped.- Returns:
- true after
stopPropagation()orCancelable.consume()
-