Class MouseEventTrigger

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ClickTrigger, DoubleClickTrigger

public class MouseEventTrigger extends DomEventTrigger
Common super class for triggers that fire on a DOM MouseEventClickTrigger, DoubleClickTrigger, and any future mouse-event trigger. Exposes the MouseEvent properties shared by all of them as static Action.Input fields on MouseEventTrigger.EventData.

The EventData fields are bound to MouseEventTrigger.class, so the same field instance can be used as the source for any MouseEventTrigger subclass — both snippets below mirror the click's screen X coordinate into xField.value, one on single click, one on double click:


 ClickTrigger click = new ClickTrigger(button);
 click.triggers(new SetPropertyAction<>(xField, "value",
         ClickTrigger.EventData.screenX));

 DoubleClickTrigger dbl = new DoubleClickTrigger(button);
 dbl.triggers(new SetPropertyAction<>(xField, "value",
         DoubleClickTrigger.EventData.screenX));
 

For internal use only. May be renamed or removed in a future release.

See Also:
  • Constructor Details

    • MouseEventTrigger

      public MouseEventTrigger(Component host, String eventName)
      Creates a mouse-event trigger that fires when the host receives a DOM event with the given name. Subclasses such as ClickTrigger bind a specific event name; instantiate this class directly only when none of the dedicated subclasses fits (e.g. for "mouseover").
      Parameters:
      host - the component whose root element listens for the event, not null
      eventName - the DOM mouse-event name (e.g. "click", "mousedown"), not null