home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>Tk::Selection - Manipulate the X selection</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tk::Selection - Manipulate the X selection</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#keywords">KEYWORDS</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>Tk::Selection - Manipulate the X selection</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <P><EM>$widget</EM>-><STRONG>Selection</STRONG><EM>Option</EM>?(<EM>args</EM>)?</P>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>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).</P>
- <P>The widget object used to invoke the methods below determines which
- display is used to access the selection.
- In order to avoid conflicts with <STRONG>selection</STRONG> methods of widget classes
- (e.g. <STRONG>Text</STRONG>) this set of methods uses the prefix <STRONG>Selection</STRONG>.
- The following methods are currently supported:</P>
- <DL>
- <DT><STRONG><A NAME="item_SelectionClear"><EM>$widget</EM>-><STRONG>SelectionClear</STRONG>?(<STRONG>-selection</STRONG>=><EM>selection</EM>)?</A></STRONG><BR>
- <DD>
- If <EM>selection</EM> exists anywhere on <EM>$widget</EM>'s display, clear it
- so that no window owns the selection anymore. <EM>Selection</EM>
- 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.
- <EM>Selection</EM> defaults to PRIMARY.
- Returns an empty string.
- <P></P>
- <DT><STRONG><A NAME="item_SelectionGet"><EM>$widget</EM>-><STRONG>SelectionGet</STRONG>?(?<STRONG>-selection</STRONG>=><EM>selection</EM>?,?<STRONG>-type</STRONG>=><EM>type</EM>?)?</A></STRONG><BR>
- <DD>
- Retrieves the value of <EM>selection</EM> from <EM>$widget</EM>'s display and
- returns it as a result. <EM>Selection</EM> defaults to PRIMARY.
- <P><EM>Type</EM> 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.
- <EM>Type</EM> 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).</P>
- <P>If <EM>format</EM> 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.</P>
- <P>If the selection is returned in a non-string format, such as INTEGER
- or ATOM, the <STRONG>SelectionGet</STRONG> converts it to a list of perl
- values: atoms are converted to their
- textual names, and anything else is converted integers.</P>
- <P>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.</P>
- <P></P>
- <DT><STRONG><A NAME="item_SelectionHandle"><EM>$widget</EM>-><STRONG>SelectionHandle</STRONG>(?<STRONG>-selection</STRONG>=><EM>selection</EM>?,?<STRONG>-type</STRONG>=><EM>type</EM>?,?<STRONG>-format</STRONG>=><EM>format</EM>? <EM>callback</EM>)</A></STRONG><BR>
- <DD>
- Creates a handler for selection requests, such that <EM>callback</EM> will
- be executed whenever <EM>selection</EM> is owned by <EM>$widget</EM> and
- someone attempts to retrieve it in the form given by <EM>type</EM>
- (e.g. <EM>type</EM> is specified in the <STRONG>selection get</STRONG> command).
- <EM>Selection</EM> defaults to PRIMARY, <EM>type</EM> defaults to STRING, and
- <EM>format</EM> defaults to STRING. If <EM>callback</EM> is an empty string
- then any existing handler for <EM>$widget</EM>, <EM>type</EM>, and
- <EM>selection</EM> is removed.
- <P>When <EM>selection</EM> is requested, <EM>$widget</EM> is the selection owner,
- and <EM>type</EM> is the requested type, <EM>callback</EM> will be executed
- with two additional arguments.
- The two additional arguments
- are <EM>offset</EM> and <EM>maxBytes</EM>: <EM>offset</EM> specifies a starting
- character position in the selection and <EM>maxBytes</EM> gives the maximum
- number of bytes to retrieve. The command should return a value consisting
- of at most <EM>maxBytes</EM> of the selection, starting at position
- <EM>offset</EM>. For very large selections (larger than <EM>maxBytes</EM>)
- the selection will be retrieved using several invocations of <EM>callback</EM>
- with increasing <EM>offset</EM> values. If <EM>callback</EM> returns a string
- whose length is less than <EM>maxBytes</EM>, the return value is assumed to
- include all of the remainder of the selection; if the length of
- <EM>callback</EM>'s result is equal to <EM>maxBytes</EM> then
- <EM>callback</EM> will be invoked again, until it eventually
- returns a result shorter than <EM>maxBytes</EM>. The value of <EM>maxBytes</EM>
- will always be relatively large (thousands of bytes).</P>
- <P>If <EM>callback</EM> returns an error (e.g. via <STRONG>die</STRONG>)
- then the selection retrieval is rejected
- just as if the selection didn't exist at all.</P>
- <P>The <EM>format</EM> 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 <EM>format</EM> is
- STRING, the selection is transmitted as 8-bit ASCII characters (i.e.
- just in the form returned by <EM>command</EM>).</P>
- <P>If <EM>format</EM> 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.</P>
- <P>If <EM>format</EM> is
- ATOM, then the return value from <EM>command</EM> 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 <EM>format</EM>, the return value from <EM>command</EM> 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.</P>
- <P>The <EM>format</EM> 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 <EM>format</EM> is
- irrelevant.</P>
- <P>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.</P>
- <DL>
- <DT><STRONG><A NAME="item_SelectionOwner"><EM>$widget</EM>-><STRONG>SelectionOwner</STRONG>?(<STRONG>-selection</STRONG>=><EM>selection</EM>)?</A></STRONG><BR>
- <DD>
- <STRONG>SelectionOwner</STRONG> returns the
- window in this application that owns <EM>selection</EM> on the display
- containing <EM>$widget</EM>, or an empty string if no window in this
- application owns the selection. <EM>Selection</EM> defaults to PRIMARY.
- <P></P>
- <DT><STRONG><A NAME="item_SelectionOwn"><EM>$widget</EM>-><STRONG>SelectionOwn</STRONG>?(?<STRONG>-command</STRONG>=><EM>callback</EM>?,?<STRONG>-selection</STRONG>=><EM>selection</EM>?)?</A></STRONG><BR>
- <DD>
- <STRONG>SelectionOwn</STRONG> causes <EM>$widget</EM> to become
- the new owner of <EM>selection</EM> on <EM>$widget</EM>'s display, returning
- an empty string as result. The existing owner, if any, is notified
- that it has lost the selection.
- If <EM>callback</EM> is specified, it will be executed when
- some other window claims ownership of the selection away from
- <EM>$widget</EM>. <EM>Selection</EM> defaults to PRIMARY.
- <P></P></DL>
- </DL>
- <P>
- <HR>
- <H1><A NAME="keywords">KEYWORDS</A></H1>
- <P>clear, format, handler, ICCCM, own, selection, target, type</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tk::Selection - Manipulate the X selection</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-