Clipboard

expect object Clipboard

A wrapper for coping and pasting text. Within a JVM, it uses AWT's Clipboard class. Within a Browser, it uses window.navigator.clipboard.

Glok doesn't currently support copy/paste of other data types.

actual object Clipboard

This interface was first designed to work in a JVM context, where it was possible to monitor the state of the clipboard. This isn't possible within a Javascript application, therefore containsText always returns true. This means that application's Edit menus will never have disabled items for Paste (even when the clipboard contains no text).

NOTE. For security reasons, when the user initiates a paste operation, the browser will likely ask the user for consent. In Firefox, a small pop-up menu appears every time, with a single menu item labelled "Paste". In Chrome, it is a pop-up dialog which with the options al Allow or Block. This only appears once, not for every paste operation. These may be affected by browser settings.

actual object Clipboard : ClipboardOwner

Exposes the system clipboard for copy/paste operations.

Currently only text is supported.

Get/set the contents of text using textContents.

Properties

Link copied to clipboard
expect var containsText: Boolean
actual var containsText: Boolean
actual var containsText: Boolean
Link copied to clipboard

Does the clipboard currently contain text.

Does the clipboard currently contain text.

Does the clipboard currently contain text.

Link copied to clipboard

The opposite of containsTextProperty. Use this as the disabledProperty for Paste menu items/buttons.

The opposite of containsTextProperty. Use this as the disabledProperty for paste actions.

The opposite of containsTextProperty. Use this as the disabledProperty for paste actions.

Link copied to clipboard
actual var textContents: String?
actual var textContents: String?

Functions

Link copied to clipboard
expect fun copyPlainText(text: String)

Copies text to the system's clipboard, where it can be used by any application (including this one).

actual fun copyPlainText(text: String)
actual fun copyPlainText(text: String)
Link copied to clipboard
open override fun lostOwnership(p0: Clipboard?, p1: Transferable?)
Link copied to clipboard
expect fun pastePlainText(block: (String) -> Unit)

Retrieves the system clipboard's contents, and if it contains plain text, then block is passed the text. Otherwise block is not executed. Within the JVM this will happen immediately, but within a web browser, it will be delayed (as it is implemented using a Promise).

actual fun pastePlainText(block: (String) -> Unit)
actual fun pastePlainText(block: (String) -> Unit)