Class DomEventTrigger
java.lang.Object
com.vaadin.flow.component.trigger.internal.Trigger
com.vaadin.flow.component.trigger.internal.DomEventTrigger
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ClickTrigger
Fires when the host component receives a DOM event with the given name. The
bound actions run inside the browser's event handler, preserving the
user-gesture context (so downstream actions may invoke APIs gated on a
gesture, such as clipboard or fullscreen).
Examples:
new DomEventTrigger(button, "click").triggers(action);
new DomEventTrigger(input, "input").triggers(action);
new DomEventTrigger(panel, "pointerdown").triggers(action);
For internal use only. May be renamed or removed in a future release.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDomEventTrigger(Component host, String eventName) Creates a trigger that fires when the host receives a DOM event with the given name. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringBuilds the JS expression that installs this trigger's listener and returns a cleanup function that removes it.<T> Action.Input<T> Returns anAction.Inputthat yieldsevent[name]at fire time — the value of a property on the DOM event object.
-
Constructor Details
-
DomEventTrigger
Creates a trigger that fires when the host receives a DOM event with the given name.- Parameters:
host- the component whose root element listens for the event, notnulleventName- the DOM event name (e.g."click","input"), notnull
-
-
Method Details
-
property
Returns anAction.Inputthat yieldsevent[name]at fire time — the value of a property on the DOM event object.The returned input is only valid in actions wired to this trigger; using it elsewhere throws
IllegalArgumentExceptionat theTrigger.triggers(Action...)call site.- Type Parameters:
T- the runtime type of the value produced- Parameters:
name- the event property name (e.g."screenX","key"), notnull- Returns:
- an input that resolves to
event[name]on fire
-
installJs
Description copied from class:TriggerBuilds the JS expression that installs this trigger's listener and returns a cleanup function that removes it.The expression runs with
thisbound to the host element. The handlerJsFunctionis available as$0; subclasses pass it to whatever client API the trigger wraps (e.g.this.addEventListener(name, $0)) and reference the same$0in the cleanup callback to detach it.
-