beetlebug▾
/

clipboard get

Gives the data of a type on the clipboard.

clipboard get ?-displayof WINDOW? ?-type TYPE?

Description

Gives the data of TYPE, STRING by default. For STRING and UTF8_STRING, the text comes from the clipboard of the system when another program put text there after the last change of the app. A type with no data is an error, so a script that pastes can test the result with catch.

Options

OptionTypeDefaultDescription
-displayofwindownoneA window of the display whose clipboard gives the data.
-typestringSTRINGThe type of the data to give.

-displayof WINDOW

A window of the display whose clipboard gives the data.

ztk has one clipboard for each app, so the window only has to exist.

% clipboard clear
> clipboard append z
> clipboard get -displayof .
z
% clipboard get -displayof .nope
bad window path name ".nope"
-errorcode NONE

-type TYPE

The type of the data to give.

The name of a type that clipboard append -type filled.

% clipboard clear
> clipboard append -type FOO bar
> clipboard get -type FOO
bar
% clipboard clear
> clipboard get -type FOO
CLIPBOARD selection doesn't exist or form "FOO" not defined
-errorcode NONE

% clipboard get -type
value for "-type" missing
-errorcode NONE

Returns

The data of the type.

Examples

% clipboard clear
> clipboard append abc
> clipboard get
abc

Errors

% clipboard clear
> clipboard get
CLIPBOARD selection doesn't exist or form "STRING" not defined
-errorcode NONE

% clipboard get -format STRING
bad option "-format": must be -displayof or -type
-errorcode NONE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also