3.5.4.2. ClipboardTrigger

ClipboardTrigger is a non-visual component which allows a user to copy text from a field to the clipboard. It is defined in the facets element of the screen XML descriptor and has the following attributes:

  • input - identifier of a text field, must be a subclass of TextInputField like TextField, TextArea and so on.

  • button - identifier of a Button which triggers the copying.

For example:

<window xmlns="http://schemas.haulmont.com/cuba/screen/window.xsd" ...>
    <facets>
        <clipboardTrigger id="clipper" button="clipBtn" input="textArea"/>
    </facets>
    <layout expand="textArea" spacing="true">
        <textArea id="textArea" width="100%"/>
        <button id="clipBtn" caption="Clip text"/>
    </layout>
</window>
@Inject
private Notifications notifications;

@Subscribe("clipBtn")
private void onClipBtnClick(Button.ClickEvent event) {
    notifications.create().withCaption("Copied to clipboard").show();
}