Clipboard

Native clipboard.

Modulerequire("gui")
TypeObject

The Clipboard class can not be created by user, its instance can only be recevied by using App.GetClipboard.

// Get the default copy-paste clipboard.
const clipboard = gui.app.getClipboard('copy-paste')

// Changing the content of clipboard with multiple formats of data.
clipboard.setData([
  {type: 'text', value: 'some text'},
  {type: 'html', value: '<strong>some text</strong>'},
  {type: 'image', value: gui.Image.createFromPath('...')},
  {type: 'file-paths', value: ['/some/path']},
])

// Read data.
const data = clipboard.getData('text')
if (data.type == 'text')
  console.log(data.value)

Methods

clear()

Clear the clipboard.

setText(text)

Set text as clipboard's content.

Parameters

getText()

Return the content of clipboard as text.

Return

String

isDataAvailable(type)

Return whether the data of type is available.

Parameters

Return

Boolean

getData(type)

Get the data of type from clipboard.

You should always check the type of returned data before using it.

Parameters

Return

Clipboard::Data

setData(objects)

Set clipboard's content.

Parameters