Class Clipboard

java.lang.Object
org.vaadin.firitin.util.clipboard.Clipboard

@Deprecated(since="3.6", forRemoval=true) public class Clipboard extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
Vaadin 25.2 ships a native clipboard API, com.vaadin.flow.component.clipboard.Clipboard, which handles the browser's user-gesture (transient activation) requirement correctly by arming the action on a click: Clipboard.onClick(component) returns a binding with writeText(...) / readText(...).
Utility class for clipboard operations in a Vaadin application. This class provides methods to copy text to the clipboard and read text from the clipboard using the Clipboard API.

Note that this is helper is early experiment and may not work in all browsers, most especially in Safari, due to its incomplete handling of transient activation regarding clipboard. See test class for more details and workarounds.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    copyToClipboard(String thisIsATestText)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Copies the given text to the current user's clipboard using the Clipboard API.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Reads text from the clipboard using the Clipboard API.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Clipboard

      public Clipboard()
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • copyToClipboard

      public static void copyToClipboard(String thisIsATestText)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Copies the given text to the current user's clipboard using the Clipboard API.
      Parameters:
      thisIsATestText - the text to be copied to the clipboard
    • readFromClipboard

      public static CompletableFuture<String> readFromClipboard()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Reads text from the clipboard using the Clipboard API. This method returns a CompletableFuture that resolves to the text read from the clipboard, once the required browser round-trip is done.
      Returns:
      a CompletableFuture containing the text from the clipboard