The
-exportselection option is a standard option on several Tk widgets. As
BioDJ described, it controls the "cut-and-paste" behavior of Tk widgets, particularly in a Unix environment.
In the X Windows environment on Unix systems, there are two selection methods for cut-and-paste behavior, usually called
PRIMARY and
CLIPBOARD. Not all applications support both models.
The
CLIPBOARD model is the one you're probably most familiar with, and its the one that works on Windows and Macintosh as well. After selecting an object (for example, a range of text), the user does some explicit Copy or Cut action. Then, the user goes to another interface, perhaps in another application, and performs a Paste action.
The
PRIMARY model is implemented on Unix systems only, and not by all applications. In this model, selecting text or an object makes it the "primary selection" automatically. If the user then goes to another interface and performs a Paste operation (typically clicking the middle mouse button), then primary selection is pasted there.
All Tk widgets for which "cut-and-paste" have reasonable meanings (that is, by default a Text widget has support, but a Label doesn't) have default bindings for implementing both
CLIPBOARD style cut-and-paste (for example, Ctrl-c copies text from an Entry to the CLIPBOARD) and
PRIMARY style cut-and-paste. However, supporting the
PRIMARY model can occasioinally make an application's interface more complex or confusing for a user. The
-exportselection allows you to control whether a particular widget implements the
PRIMARY model. The default value of TRUE enables the
PRIMARY model, setting the value to FALSE disables it.
Most of the time, you just ignore all this and Tk does everything for you correctly. There are only two occasions that I can think of where you really need to be aware of how the cut-and-paste behavior is implemented:[ul][li]If you're creating your own widget using C code[/li]
[li]If you're implementing an advanced cut-and-paste behavior, such as the ability to copy and paste objects in a Canvas (perhaps for a drawing program)[/li][/ul]In either of these cases, I recommed that you read Chapter 35, "Selections and the Clipboard" from Brent Welch's
Practical Programming in Tcl and Tk, 3rd ed. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax