| [ Team LiB ] |
|
The selection CommandThere are two Tcl commands that deal with selections. The selection command is a general-purpose command that can set and get different selections. By default it manipulates the PRIMARY selection. The clipboard command is a convenience command for manipulating the CLIPBOARD selection. The selection command exposes the fully general selection model of different selections, types, and formats. You can define selection handlers that return selection values, and you can assert ownership of a selection and find out when you lose ownership to another application. Example 38-5 on page 596 shows a selection handler for a canvas. A selection can have a type. The default is STRING. The type is different than the name of the selection (e.g., PRIMARY or CLIPBOARD). Each type can have a format, and the default format is STRING. Ordinarily these defaults are fine. If you are dealing with non-Tk applications, however, you may need to ask for their selections by the right type (e.g., FILE_NAME). Formats include UTF8_STRING, STRING, ATOM, and INTEGER. An ATOM is a name that is registered with the X server and identified by number. "Atoms and IDs" on page 667 describes Tk commands for manipulating atoms. It is probably not a good idea to use non-STRING types and formats because it limits what other applications can use the information. The details about X selection types and formats are specified in the Inter-Client Communication Conventions Manual (David Rosenthal, Stuart Marks, X Consortium Standard). This is distributed with the X11 sources and can be found on the web at http://tronche.com/gui/x/icccm/. All of the selection operations take a -selection option that specifies the name of the selection being manipulated. This defaults to PRIMARY. Some of the operations take a -displayof option that specifies what display the selection is on. The value for this option is a Tk pathname of a window, and the selection on that window's display is manipulated. This is useful in X where applications can have their windows on remote displays. The default is to manipulate the selection on the display of the main window. Table 38-1 summarizes the selection command:
|
| [ Team LiB ] |
|