Clipboard

Native clipboard.

Modulerequire("yue.gui")
Typetable

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.
local 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.
local data = clipboard:getdata('text')
if data.type == 'text' then
  print(data.value)
end

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