Class ClipboardCopyAction

java.lang.Object
com.vaadin.flow.component.trigger.AbstractAction
com.vaadin.flow.component.trigger.ClipboardCopyAction
All Implemented Interfaces:
Action, Serializable

public class ClipboardCopyAction extends AbstractAction
Copies a value to the user's clipboard via navigator.clipboard.writeText.

The Clipboard API requires the call to happen inside a short-lived user gesture (click, key press, …). Bind this action to a Trigger that fires during such a gesture, e.g. ClickTrigger.


 Output<String> value = new PropertyOutput<>(textField, "value",
         String.class);
 new ClickTrigger(button).triggers(new ClipboardCopyAction(value));
 
See Also:
  • Field Details

  • Constructor Details

    • ClipboardCopyAction

      public ClipboardCopyAction(Output<String> textOutput)
      Creates a clipboard-copy action that copies the value produced by the given output.
      Parameters:
      textOutput - the output supplying the text to copy, not null
  • Method Details

    • getTextOutput

      public Output<String> getTextOutput()
      Returns:
      the output supplying the text
    • buildClientConfig

      public tools.jackson.databind.node.ObjectNode buildClientConfig(ConfigContext context)
      Description copied from class: AbstractAction
      Produces the JSON configuration this action sends to the client. Default is an empty object; override to add type-specific options.

      Subclasses encode output references by calling ConfigContext.registerOutput(Output) and element references by calling ConfigContext.referenceElement(com.vaadin.flow.dom.Element). Public so the internal framework can read the config without reflection; subclasses just override.

      Overrides:
      buildClientConfig in class AbstractAction
      Parameters:
      context - the resolver for referenced elements and outputs, not null
      Returns:
      a Jackson ObjectNode, never null