Class Clipboard
java.lang.Object
org.vaadin.firitin.util.clipboard.Clipboard
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic void
copyToClipboard
(String thisIsATestText) Copies the given text to the current user's clipboard using the Clipboard API.static CompletableFuture<String>
Reads text from the clipboard using the Clipboard API.
-
Constructor Details
-
Clipboard
public Clipboard()
-
-
Method Details
-
copyToClipboard
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
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
-