Here is the code for the Vaadin button:
String textToCopy = "COPY ME!!!";
Button copyBtn = new Button("");
copyBtn.setButtonLayout(false, new IconSelf(VaadinIcon.COPY_O), "Copy"));
copyBtn.addClickListener(event -> {
getUI().get().getPage().executeJs("navigator.clipboard.writeText(`" + textToCopy + "`);");
Notification.show(getTranslation(PAGESTRING + "attributestoclipboard"))
});
To copy my custom text I used navigator.clipboard.writeText(...).
Works in Chrome and Edge but not in Firefox.
Firefox also blocked document.execCommand("copy") when i used it in the executeJS(...) function.
I think i need to add a onClick function to the button. How can i do this with Vaadin?