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 Type
    Method
    Description
    Returns what led to the event: the objects the change passed through and the context, such as who caused it and with which device.
    Returns the component whose handlers or default behavior are running now.
    boolean
    Returns whether propagation was stopped.
    Returns who caused the event, without making the whole cause.
    void
    Keeps the event from reaching any further ancestor.
    Returns the component the event was fired at.
  • Method Details

    • target

      Component<?> target()
      Returns the component the event was fired at.
      Returns:
      the target; never null
    • current

      Component<?> current()
      Returns the component whose handlers or default behavior are running now. Equal to target() at first; while a bubbling event travels up, it is each ancestor in turn.
      Returns:
      the current component; never null
    • 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.CODE when 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() or Cancelable.consume()