Clipboard

Supported from HBuilderX 2.7.6+

The clipboard provides read and write access to the system’s clipboard. Currently, only text format is supported.

readText

Read the current clipboard contents as text.

Parameter Description

No parameters

Returns

Type Description
Promise<String> A promise that resolves to a string.

Example

  1. var readPromise = hx.env.clipboard.readText();
  2. readPromise.then(function(text) {
  3. console.log("Read clipboard content:",text);
  4. });

writeText

Writes text into the clipboard.

Parameter Description

Parameter Type Description
value String The string to be written to the clipboard

Returns

Type Description
Promise<void> Promise

Example

  1. hx.env.clipboard.writeText("Hello Clipboard.");