Interface Event

All Superinterfaces:
Event
All Known Subinterfaces:
CustomEvent, KeyEvent, MouseEvent, UiEventModifier, WheelEvent

public interface Event extends Event
A DOM event, for example, mouse or keyboard event, provides access to the event data and methods to change the event behavior.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an Optional that contains the event target that represents the element to which the event handler has been attached, otherwise an empty Optional.
    boolean
    Returns true if the event bubbles up through the DOM, otherwise false.
    boolean
    Returns true when the event can be canceled, and therefore prevented as if the event never happened.
    boolean
    Returns true if the event is trusted, and therefore was generated by a user action.
    Returns the event phase.
    void
    Informs the browser that if the event is not explicitly handled, its default action should not be performed.
    void
    Informs the browser that the event should not propagate in the capturing and bubbling phases.
    Returns an Optional that contains the element on which the event occurred if it exists, otherwise an empty Optional.
    Returns the event type.
  • Method Details

    • type

      EventType type()
      Returns the event type.
    • target

      Returns an Optional that contains the element on which the event occurred if it exists, otherwise an empty Optional.
    • currentTarget

      Optional<EventTarget> currentTarget()
      Returns an Optional that contains the event target that represents the element to which the event handler has been attached, otherwise an empty Optional.
    • phase

      EventPhase phase()
      Returns the event phase.
    • isBubbles

      boolean isBubbles()
      Returns true if the event bubbles up through the DOM, otherwise false.
    • isCancelable

      boolean isCancelable()
      Returns true when the event can be canceled, and therefore prevented as if the event never happened. In other case, returns false.
    • isTrusted

      boolean isTrusted()
      Returns true if the event is trusted, and therefore was generated by a user action.
      Since:
      7.12
    • preventDefault

      void preventDefault()
      Informs the browser that if the event is not explicitly handled, its default action should not be performed.

      For example, if you invoke this method for the event of the EventType.CLICK type, dispatching this event to the checkbox element as the event currentTarget will not toggle this checkbox.

      Throws:
      ObjectClosedException - if the event is closed
    • stopPropagation

      void stopPropagation()
      Informs the browser that the event should not propagate in the capturing and bubbling phases.
      Throws:
      ObjectClosedException - if the event is closed