1selection(3)          User Contributed Perl Documentation         selection(3)
2
3
4

NAME

6       Tk::Selection - Manipulate the X selection
7

SYNOPSIS

9       $widget->SelectionOption?(args)?
10

DESCRIPTION

12       This command provides an interface to the X selection mechanism and
13       implements the full selection functionality described in the X Inter-
14       Client Communication Conventions Manual (ICCCM).
15
16       The widget object used to invoke the methods below determines which
17       display is used to access the selection.  In order to avoid conflicts
18       with selection methods of widget classes (e.g. Text) this set of
19       methods uses the prefix Selection.  The following methods are currently
20       supported:
21
22       $widget->SelectionClear?(-selection=>selection)?
23           If selection exists anywhere on $widget's display, clear it so that
24           no window owns the selection anymore.  Selection specifies the X
25           selection that should be cleared, and should be an atom name such
26           as PRIMARY or CLIPBOARD; see the Inter-Client Communication
27           Conventions Manual for complete details.  Selection defaults to
28           PRIMARY.  Returns an empty string.
29
30       $widget->SelectionGet?(?-selection=>selection?,?-type=>type?)?
31           Retrieves the value of selection from $widget's display and returns
32           it as a result.  Selection defaults to PRIMARY.
33
34           Type specifies the form in which the selection is to be returned
35           (the desired ``target'' for conversion, in ICCCM terminology), and
36           should be an atom name such as STRING or FILE_NAME; see the Inter-
37           Client Communication Conventions Manual for complete details.  Type
38           defaults to STRING.  The selection owner may choose to return the
39           selection in any of several different representation formats, such
40           as STRING, ATOM, INTEGER, etc. (this format is different than the
41           selection type; see the ICCCM for all the confusing details).
42
43           If format is not STRING then things get messy, the following
44           description is from the Tcl/Tk man page as yet incompetely
45           translated for the perl version - it is misleading at best.
46
47           If the selection is returned in a non-string format, such as
48           INTEGER or ATOM, the SelectionGet converts it to a list of perl
49           values: atoms are converted to their textual names, and anything
50           else is converted integers.
51
52           A goal of the perl port is to provide better handling of different
53           formats than Tcl/Tk does, which should be possible given perl's
54           wider range of ``types''. Although some thought went into this in
55           very early days of perl/Tk what exactly happens is still "not quite
56           right" and subject to change.
57
58       $widget->SelectionHandle(?-selection=>selection?,?-type=>type?,?-format=>format?
59       callback)
60           Creates a handler for selection requests, such that callback will
61           be executed whenever selection is owned by $widget and someone
62           attempts to retrieve it in the form given by type (e.g. type is
63           specified in the selection get command).  Selection defaults to
64           PRIMARY, type defaults to STRING, and format defaults to STRING.
65           If callback is an empty string then any existing handler for
66           $widget, type, and selection is removed.
67
68           When selection is requested, $widget is the selection owner, and
69           type is the requested type, callback will be executed with two
70           additional arguments.  The two additional arguments are offset and
71           maxBytes:  offset specifies a starting character position in the
72           selection and maxBytes gives the maximum number of bytes to
73           retrieve.  The command should return a value consisting of at most
74           maxBytes of the selection, starting at position offset.  For very
75           large selections (larger than maxBytes) the selection will be
76           retrieved using several invocations of callback with increasing
77           offset values.  If callback returns a string whose length is less
78           than maxBytes, the return value is assumed to include all of the
79           remainder of the selection;  if the length of callback's result is
80           equal to maxBytes then callback will be invoked again, until it
81           eventually returns a result shorter than maxBytes.  The value of
82           maxBytes will always be relatively large (thousands of bytes).
83
84           If callback returns an error (e.g. via die) then the selection
85           retrieval is rejected just as if the selection didn't exist at all.
86
87           The format argument specifies the representation that should be
88           used to transmit the selection to the requester (the second column
89           of Table 2 of the ICCCM), and defaults to STRING.  If format is
90           STRING, the selection is transmitted as 8-bit ASCII characters
91           (i.e.  just in the form returned by command).
92
93           If format is not STRING then things get messy, the following
94           description is from the Tcl/Tk man page as yet untranslated for the
95           perl version - it is misleading at best.
96
97           If format is ATOM, then the return value from command is divided
98           into fields separated by white space;  each field is converted to
99           its atom value, and the 32-bit atom value is transmitted instead of
100           the atom name.  For any other format, the return value from command
101           is divided into fields separated by white space and each field is
102           converted to a 32-bit integer;  an array of integers is transmitted
103           to the selection requester.
104
105           The format argument is needed only for compatibility with many
106           selection requesters, except Tcl/Tk.  If Tcl/Tk is being used to
107           retrieve the selection then the value is converted back to a string
108           at the requesting end, so format is irrelevant.
109
110           A goal of the perl port is to provide better handling of different
111           formats than Tcl/Tk does, which should be possible given perl's
112           wider range of ``types''. Although some thought went into this in
113           very early days of perl/Tk what exactly happens is still "not quite
114           right" and subject to change.
115
116       $widget->SelectionOwner?(-selection=>selection)?
117           SelectionOwner returns the window in this application that owns
118           selection on the display containing $widget, or an empty string if
119           no window in this application owns the selection.  Selection
120           defaults to PRIMARY.
121
122       $widget->SelectionOwn?(?-command=>callback?,?-selection=>selection?)?
123           SelectionOwn causes $widget to become the new owner of selection on
124           $widget's display, returning an empty string as result. The
125           existing owner, if any, is notified that it has lost the selection.
126           If callback is specified, it will be executed when some other
127           window claims ownership of the selection away from $widget.
128           Selection defaults to PRIMARY.
129

KEYWORDS

131       clear, format, handler, ICCCM, own, selection, target, type
132
133
134
135perl v5.34.0                      2021-07-23                      selection(3)
Impressum