Interface FocusEvent

All Superinterfaces:
Cancelable, Event, SnapshotEvent

public interface FocusEvent extends SnapshotEvent
Keyboard focus moving. Used by Focusable.FOCUS_GAINED and Focusable.FOCUS_LOST. When focus moves from one component to another, the old one gets FOCUS_LOST first, then the new one gets FOCUS_GAINED; both run after the focus has already changed. Canceling the event cannot undo the move; it skips the component's default behavior, such as a text box moving its caret.

Only Strata creates events. Do not implement this interface.

  • Method Details

    • other

      Optional<Component<?>> other()
      Returns the other side of the move.
      Returns:
      for a gain, the component that lost focus; for a loss, the component that gained it; empty when focus came from or went to nothing
    • reason

      FocusReason reason()
      Returns why focus moved. A loss and the gain that follows it report the same reason.
      Returns:
      the reason