[wxPython-users] Re: wx.py.shell multiline input

Robin Dunn robin at alldunn.com
Mon Mar 5 10:35:22 PST 2007


Christian wrote:

> 
> Ok. I found the relevant parts, but as as I am working on linux I'm wondering
> how the middle-click paste works. I always supposed that it simulates key
> strokes, but it doesn't. Sometimes it seems to me that there are two types of
> clipboards on unix, one which is accessed with the ctrl keystrokes and the other
> by just selecting and middle clicking. Most programs however obviously can do
> both but e.g. emacs can't. Therefore I'd really like to understand how the
> middle-click works and how I can intercept that with wxPython.

You are right.  Googling for "primary selection" will probably turn up 
more info, but in a nutshell it works like this:

* There are actually 3 "clipboards" available on X-windows systems, the 
"primary selection", the "secondary selection" and the "clipboard".

* I don't think that the secondary selection is used at all any more.

* The clipboard is used as you would expect if coming from a MS-Windows 
perspective.  It's the one used for typical copy/paste operations using 
the keyboard or menu items, and can hold data objects that are not only 
text.

* The primary selection is used differently.  Whenever text is selected 
in an application, the app is supposed to acquire the primary selection 
from the system and make the selected text available through it.  No 
other action is required on the user's part, other than 
selecting/marking the text with the mouse.  Text is typically pasted 
from the primary selection using the middle mouse button.

* In wxWidgets you control whether the primary selection or the 
clipboard is used by calling wx.TheCLipboard.UsePrimarySelection before 
doing other clipboard operations.

* Unfortunately, wxWidgets doesn't support supplying data to both 
clipboards at the same time.  For example, you can't have one chunk of 
text in the main clipboard, and then put something else in the primary 
selection when the user selects some text.  If you try doing this then 
the value in the clipboard will be lost.  For this reason if you look in 
the STC C++ code you'll see some code commented out that would otherwise 
put the selected text in the primary selection.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list