diff options
Diffstat (limited to 'doc/selection.n')
-rw-r--r-- | doc/selection.n | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/doc/selection.n b/doc/selection.n index 44fda07..c4847e7 100644 --- a/doc/selection.n +++ b/doc/selection.n @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: selection.n,v 1.4 2001/06/04 03:15:20 hobbs Exp $ +'\" RCS: @(#) $Id: selection.n,v 1.4.4.1 2004/10/28 12:25:22 dkf Exp $ '\" .so man.macros .TH selection n 8.1 Tk "Tk Built-In Commands" @@ -128,9 +128,43 @@ that it has lost the selection. If \fIcommand\fR is specified, it is a Tcl script to execute when some other window claims ownership of the selection away from \fIwindow\fR. \fISelection\fR defaults to PRIMARY. +.SH EXAMPLES +On X11 platforms, one of the standard selections available is the +SECONDARY selection. Hardly anything uses it, but here is how to read +it using Tk: +.CS +set selContents [\fBselection get\fR \-selection SECONDARY] +.CE +.PP +Many different types of data may be available for a selection; the +special type TARGETS allows you to get a list of available types: +.CS +foreach type [\fBselection get\fR \-type TARGETS] { + puts "Selection PRIMARY supports type $type" +} +.CE +.PP +To claim the selection, you must first set up a handler to supply the +data for the selection. Then you have to claim the selection... +.CS +# Set up the data handler ready for incoming requests +set foo "This is a string with some data in it... blah blah" +\fBselection handle\fR \-selection SECONDARY . getData +proc getData {offset maxChars} { + puts "Retrieving selection starting at $offset" + return [string range $::foo $offset [expr {$offset+$maxChars}]] +} + +# Now we grab the selection itself +puts "Claiming selection" +\fBselection own\fR \-command lost \-selection SECONDARY . +proc lost {} { + puts "Lost selection" +} +.CE .SH "SEE ALSO" -clipboard +clipboard(n) .SH KEYWORDS clear, format, handler, ICCCM, own, selection, target, type |