selection get
Gives the data of a selection.
selection get ?-displayof WINDOW? ?-selection NAME? ?-type TYPE?
Description
Runs the handler of the owner for TYPE, and gives the data. For the type STRING, a handler of UTF8_STRING also works. The selection CLIPBOARD with no owner or with no handler gives the text of the clipboard.
A selection with no owner, or an owner with no handler of the type, is an error.
Options
| Option | Type | Default | Description |
|---|---|---|---|
-displayof | window | none | A window of the display of the selection. |
-selection | string | PRIMARY | The name of the selection to read. |
-type | string | STRING | The type of the data to read. |
-displayof WINDOW
A window of the display of the selection.
ztk has one display for each app, so the value has no effect.
% frame .g1
> selection handle .g1 list
> selection own .g1
> selection get -displayof .
0 4000ztk accepts any value of -displayof.
-selection NAME
The name of the selection to read.
CLIPBOARD gives the text of the clipboard when no window owns it.
% clipboard clear
> clipboard append text
> selection get -selection CLIPBOARD
text% selection get -selection SECONDARY
SECONDARY selection doesn't exist or form "STRING" not defined
-errorcode NONE-type TYPE
The type of the data to read.
The owner needs a handler of this type.
% frame .g2
> selection handle -type MYTYPE .g2 list
> selection own .g2
> selection get -type MYTYPE
0 4000% frame .g3
> selection own .g3
> selection get -type MYTYPE
PRIMARY selection doesn't exist or form "MYTYPE" not defined
-errorcode NONEReturns
The data of the selection.
Examples
% clipboard clear
> clipboard append copied
> selection get -selection CLIPBOARD
copied
Errors
% selection clear
> selection get
PRIMARY selection doesn't exist or form "STRING" not defined
-errorcode NONE
% selection get -foo 1
bad option "-foo": must be -displayof, -selection, or -type
-errorcode NONE
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1