.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "selection 3pm" .TH selection 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Tk::Selection \- Manipulate the X selection .SH SYNOPSIS .IX Header "SYNOPSIS" \&\fR\f(CI$widget\fR\fI\fR\->\fBSelection\fR\fIOption\fR?(\fIargs\fR)? .SH DESCRIPTION .IX Header "DESCRIPTION" This command provides an interface to the X selection mechanism and implements the full selection functionality described in the X Inter-Client Communication Conventions Manual (ICCCM). .PP The widget object used to invoke the methods below determines which display is used to access the selection. In order to avoid conflicts with \fBselection\fR methods of widget classes (e.g. \fBText\fR) this set of methods uses the prefix \fBSelection\fR. The following methods are currently supported: .ie n .IP \fR\fI$widget\fR\fI\fR\->\fBSelectionClear\fR?(\fB\-selection\fR=>\fIselection\fR)? 4 .el .IP \fR\f(CI$widget\fR\fI\fR\->\fBSelectionClear\fR?(\fB\-selection\fR=>\fIselection\fR)? 4 .IX Item "$widget->SelectionClear?(-selection=>selection)?" If \fIselection\fR exists anywhere on \fR\f(CI$widget\fR\fI\fR's display, clear it so that no window owns the selection anymore. \fISelection\fR specifies the X selection that should be cleared, and should be an atom name such as PRIMARY or CLIPBOARD; see the Inter-Client Communication Conventions Manual for complete details. \&\fISelection\fR defaults to PRIMARY. Returns an empty string. .ie n .IP \fR\fI$widget\fR\fI\fR\->\fBSelectionGet\fR?(?\fB\-selection\fR=>\fIselection\fR?,?\fB\-type\fR=>\fItype\fR?)? 4 .el .IP \fR\f(CI$widget\fR\fI\fR\->\fBSelectionGet\fR?(?\fB\-selection\fR=>\fIselection\fR?,?\fB\-type\fR=>\fItype\fR?)? 4 .IX Item "$widget->SelectionGet?(?-selection=>selection?,?-type=>type?)?" Retrieves the value of \fIselection\fR from \fR\f(CI$widget\fR\fI\fR's display and returns it as a result. \fISelection\fR defaults to PRIMARY. .Sp \&\fIType\fR specifies the form in which the selection is to be returned (the desired ``target'' for conversion, in ICCCM terminology), and should be an atom name such as STRING or FILE_NAME; see the Inter-Client Communication Conventions Manual for complete details. \&\fIType\fR defaults to STRING. The selection owner may choose to return the selection in any of several different representation formats, such as STRING, ATOM, INTEGER, etc. (this format is different than the selection type; see the ICCCM for all the confusing details). .Sp If \fIformat\fR is not STRING then things get messy, the following description is from the Tcl/Tk man page as yet incompetely translated for the perl version \- it is misleading at best. .Sp If the selection is returned in a non-string format, such as INTEGER or ATOM, the \fBSelectionGet\fR converts it to a list of perl values: atoms are converted to their textual names, and anything else is converted integers. .Sp A goal of the perl port is to provide better handling of different formats than Tcl/Tk does, which should be possible given perl's wider range of ``types''. Although some thought went into this in very early days of perl/Tk what exactly happens is still "not quite right" and subject to change. .ie n .IP "\fR\fI$widget\fR\fI\fR\->\fBSelectionHandle\fR(?\fB\-selection\fR=>\fIselection\fR?,?\fB\-type\fR=>\fItype\fR?,?\fB\-format\fR=>\fIformat\fR? \fIcallback\fR)" 4 .el .IP "\fR\f(CI$widget\fR\fI\fR\->\fBSelectionHandle\fR(?\fB\-selection\fR=>\fIselection\fR?,?\fB\-type\fR=>\fItype\fR?,?\fB\-format\fR=>\fIformat\fR? \fIcallback\fR)" 4 .IX Item "$widget->SelectionHandle(?-selection=>selection?,?-type=>type?,?-format=>format? callback)" Creates a handler for selection requests, such that \fIcallback\fR will be executed whenever \fIselection\fR is owned by \fR\f(CI$widget\fR\fI\fR and someone attempts to retrieve it in the form given by \fItype\fR (e.g. \fItype\fR is specified in the \fBselection get\fR command). \&\fISelection\fR defaults to PRIMARY, \fItype\fR defaults to STRING, and \&\fIformat\fR defaults to STRING. If \fIcallback\fR is an empty string then any existing handler for \fI\fR\f(CI$widget\fR\fI\fR, \fItype\fR, and \&\fIselection\fR is removed. .Sp When \fIselection\fR is requested, \fR\f(CI$widget\fR\fI\fR is the selection owner, and \fItype\fR is the requested type, \fIcallback\fR will be executed with two additional arguments. The two additional arguments are \fIoffset\fR and \fImaxBytes\fR: \fIoffset\fR specifies a starting character position in the selection and \fImaxBytes\fR gives the maximum number of bytes to retrieve. The command should return a value consisting of at most \fImaxBytes\fR of the selection, starting at position \&\fIoffset\fR. For very large selections (larger than \fImaxBytes\fR) the selection will be retrieved using several invocations of \fIcallback\fR with increasing \fIoffset\fR values. If \fIcallback\fR returns a string whose length is less than \fImaxBytes\fR, the return value is assumed to include all of the remainder of the selection; if the length of \&\fIcallback\fR's result is equal to \fImaxBytes\fR then \&\fIcallback\fR will be invoked again, until it eventually returns a result shorter than \fImaxBytes\fR. The value of \fImaxBytes\fR will always be relatively large (thousands of bytes). .Sp If \fIcallback\fR returns an error (e.g. via \fBdie\fR) then the selection retrieval is rejected just as if the selection didn't exist at all. .Sp The \fIformat\fR argument specifies the representation that should be used to transmit the selection to the requester (the second column of Table 2 of the ICCCM), and defaults to STRING. If \fIformat\fR is STRING, the selection is transmitted as 8\-bit ASCII characters (i.e. just in the form returned by \fIcommand\fR). .Sp If \fIformat\fR is not STRING then things get messy, the following description is from the Tcl/Tk man page as yet untranslated for the perl version \- it is misleading at best. .Sp If \fIformat\fR is ATOM, then the return value from \fIcommand\fR is divided into fields separated by white space; each field is converted to its atom value, and the 32\-bit atom value is transmitted instead of the atom name. For any other \fIformat\fR, the return value from \fIcommand\fR is divided into fields separated by white space and each field is converted to a 32\-bit integer; an array of integers is transmitted to the selection requester. .Sp The \fIformat\fR argument is needed only for compatibility with many selection requesters, except Tcl/Tk. If Tcl/Tk is being used to retrieve the selection then the value is converted back to a string at the requesting end, so \fIformat\fR is irrelevant. .Sp A goal of the perl port is to provide better handling of different formats than Tcl/Tk does, which should be possible given perl's wider range of ``types''. Although some thought went into this in very early days of perl/Tk what exactly happens is still "not quite right" and subject to change. .ie n .IP \fR\fI$widget\fR\fI\fR\->\fBSelectionOwner\fR?(\fB\-selection\fR=>\fIselection\fR)? 4 .el .IP \fR\f(CI$widget\fR\fI\fR\->\fBSelectionOwner\fR?(\fB\-selection\fR=>\fIselection\fR)? 4 .IX Item "$widget->SelectionOwner?(-selection=>selection)?" \&\fBSelectionOwner\fR returns the window in this application that owns \fIselection\fR on the display containing \fR\f(CI$widget\fR\fI\fR, or an empty string if no window in this application owns the selection. \fISelection\fR defaults to PRIMARY. .ie n .IP \fR\fI$widget\fR\fI\fR\->\fBSelectionOwn\fR?(?\fB\-command\fR=>\fIcallback\fR?,?\fB\-selection\fR=>\fIselection\fR?)? 4 .el .IP \fR\f(CI$widget\fR\fI\fR\->\fBSelectionOwn\fR?(?\fB\-command\fR=>\fIcallback\fR?,?\fB\-selection\fR=>\fIselection\fR?)? 4 .IX Item "$widget->SelectionOwn?(?-command=>callback?,?-selection=>selection?)?" \&\fBSelectionOwn\fR causes \fR\f(CI$widget\fR\fI\fR to become the new owner of \fIselection\fR on \fI\fR\f(CI$widget\fR\fI\fR's display, returning an empty string as result. The existing owner, if any, is notified that it has lost the selection. If \fIcallback\fR is specified, it will be executed when some other window claims ownership of the selection away from \&\fI\fR\f(CI$widget\fR\fI\fR. \fISelection\fR defaults to PRIMARY. .SH KEYWORDS .IX Header "KEYWORDS" clear, format, handler, ICCCM, own, selection, target, type