conflict between selecting text and DnD?



I guess I should have expected this, but I didn't.

I have a little toy PyGtk (gtk+ 1.3.x) script with four widgets in a
GtkTable.  One button and one entry widget are each defined as drag sources
and another button and entry are defined as drag destinations.  Both of the
entry widgets are initialized with some text.  Both sources are initialized
like so:

    source.drag_source_set(gtk.GDK.BUTTON1_MASK,
                           self.target,
                           (gtk.GDK.ACTION_DEFAULT|
                            gtk.GDK.ACTION_COPY|
                            gtk.GDK.ACTION_MOVE))

The drag-begin signal is connected to like so:

    source.connect("drag-begin", self.start)

and the start method of my drag-n-drop class looks like this:

    def start(self, source, *extra):
        self.source = source
        return gtk.TRUE

In the source entry widget I can't reliably select text or initiate drags
with the left mouse button.  If I try, sometimes it selects a couple
characters before it initiates the drag.  Sometimes the drag starts
immediately. Even when drags are happening in the source widget (the cursor
has changed to the active drag thing), the insertion cursor in the entry
widget moves with the mouse.

"No problem", I thought.  "I'll just change the drag source modifier mask."
Riiiight...  In theory, while this is possible, in practice it turns out to
be more difficult than one would expect because I am using a laptop with a
two-button scratchpad as an input device.  I also have a two-button mouse,
but I'm not using it at the moment, and in any case I think I would
encounter similar problems.  If I change the mask to BUTTON2_MASK, I have
trouble getting the drag started because it's challenging to click both
buttons simultaneously enough to get the chorded middle button.  (I don't
seem to have this problem with other applications like Netscape.)  If I
change the mask to BUTTON3_MASK I get a popup menu with cut, copy, paste,
and input methods entries, but no drag functionality.  If I change the mask
to SHIFT_MASK|BUTTON1_MASK or CONTROL_MASK|BUTTON1_MASK, the drag still
starts without the shift key, so I can't drag with button 1 to select text.

On top of this I have to wonder if this can be set from a style file or if I
have to hard code this into my source?

I'm using Mandrake 8.0 and the XFree86 4.0.3 that came with it.

Is there some way to resolve these ambiguities?

Thx,

-- 
Skip Montanaro (skip pobox com)
http://www.mojam.com/
http://www.musi-cal.com/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]