Class Clipboard
java.lang.Object
com.vaadin.flow.component.clipboard.Clipboard
- All Implemented Interfaces:
Serializable
Entry point for the browser clipboard API. Bind clipboard actions to a user
gesture by chaining off
onClick(Component):
Button copyButton = new Button("Copy");
Clipboard.onClick(copyButton).writeText(textField);
Clipboard.onClick(copyButton)
.write(ClipboardContent.create().text("Hello").html("<b>Hello</b>"));
The Clipboard API requires a fresh user gesture for each write, so actions
only run during the DOM event that fires the underlying trigger.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Component & ClickNotifier<?>>
ClipboardBindingonClick(T component) Registers the given component as a clickable trigger for a clipboard action — the common shape for copy-to-clipboard buttons.
-
Method Details
-
onClick
Registers the given component as a clickable trigger for a clipboard action — the common shape for copy-to-clipboard buttons. Equivalent tonew ClickTrigger(component), without making callers reach for the trigger framework's internal types.- Type Parameters:
T- the component type, must implementClickNotifier- Parameters:
component- the component to listen for clicks on, notnull- Returns:
- a new binding that can chain actions to this trigger
-