logo
24.2
search
No matching documents found.
list
search
No matching documents found.
logo

Clipboard

Webswing has a built-in clipboard integration. Due to various browser security limitations some clipboard operations are limited.

Copy

When the user triggers copy operation from the Swing application by pressing CTRL+C or in menu option, Webswing analyzes the data written to clipboard and notifies the client what type of data is available in clipboard by small dialog.

Webswing recognizes 5 basic types.

  1. Plain text
  2. HTML

html copy dialog

  1. Image

image copy dialog

  1. Files

file copy dialog

  1. Other (i.e. application specific types)

This dialog informs the user that data is available in the Swing clipboard. To copy the Plain text or HTML type to local clipboard, user can press CTRL+C again while the dialog is visible. For copying the image, the user has to use the browser default behavior to copy the image to the local clipboard.

Since version 22.2 Webswing uses browser's Clipboard API to automatically send data from Webswing to local clipboard. If user's browser supports Clipboard API the copied data will be automatically sent to local clipboard without showing the copy dialog and pressing CTRL+C again. In case user's browser does not support Clipboard API, the copy dialog shows as a fallback. Note that Clipboard API is supported only in secure contexts, i.e. only with HTTPS.

If the Swing clipboard contains files and allowDownload option is enabled, the user will be presented with a list of links allowing him to download those files from the Swing application.

Note: isolatedFs option does not apply here. Access is not limited to files in the isolated folder.

Paste

Paste operation can be triggered by CTRL+V keyboard shortcut. But here it gets a little tricky, because we have our Swing clipboard data sitting on the server and we have a local browser clipboard data. So we need to decide which one to use for the paste operation.

The solution is simple. If the clipboard dialog is open, we use the Swing clipboard, because we know the user has just copied some data there. If the clipboard is not visible, we try to get the data from the local browser clipboard.

Note: if paste operation is triggered from context menu, it will always use the Swing clipboard data.

Pasting from Swing clipboard All types are accessible to application if pasting from Swing clipboard.

Pasting from local browser clipboard See the following matrix for supported types based on browser.

Browser Supported content types
Chrome/Edge Plain text, HTML, Images
Firefox Plain text, HTML

Automatic clipboard synchronization

You can force to synchronize the local browser clipboard before pasting to Webswing using a startup option. With this option turned on, Webswing will always use the contents of local browser clipboard (if available).

var webswingInstance0 = {
    options: {
        ...
        syncClipboard: true,
        ...
    }
}

To enable the customization first follow the steps from Webswing Branding to get a custom index.html.