using drag/drop with other events without conflicting

Hi,

I am trying to create a custom color picker using wx.Panel.
In compare of a normal color picker this would give a functionality
to swap/replace color between picker using drag/drop technique.

So far drag/drop is working fine and you can check in the attached code.
Another functionality to use it as a normal picker by showing the
color dialog at mouse-up is not working on LINUX but this code is
working absolutely fine on WINDOWS.

I have noticed two things on Linux:
1. At mouse-up event 'onMotion' is getting called. I don't why it's happening?
2. On Linux platform if you don't release the mouse after capturing
    it, entire os hangs/crashes. This doesn't happens on windows. Yes,
I know that
you have to release it. Just wanted to let developers know this thing.

Idea is to implement drag/drop and picking without interfacing each other.

THIS IS OPTIONAL
I did post about this earlier but not able to implement it. While
dragging, you should see a rectangle of some
size but with the color of source rectangle. This is to give a visual
hint about source color.

The code has lot of commented paragraphs because I am experimenting
lot of things with drag/drop. I apologize
for that.

picker.py (8.89 KB)

Hi,

I am trying to create a custom color picker using wx.Panel.
In compare of a normal color picker this would give a functionality
to swap/replace color between picker using drag/drop technique.

So far drag/drop is working fine and you can check in the attached code.
Another functionality to use it as a normal picker by showing the
color dialog at mouse-up is not working on LINUX but this code is
working absolutely fine on WINDOWS.

I have noticed two things on Linux:
1. At mouse-up event 'onMotion' is getting called. I don't why it's happening?

Sometimes the platform has a very low threshold for deciding when a mouse event is a drag/motion. What I usually do to deal with this is:

a. keep track of where the left-down happened
b. in the motion event handler compare the current position to the start
c. call DoDragDrop only after the position is more than 3 or 4 pixels away from the starting position.

2. On Linux platform if you don't release the mouse after capturing
     it, entire os hangs/crashes. This doesn't happens on windows. Yes,
I know that
you have to release it. Just wanted to let developers know this thing.

Yep this is known, and is a typical problem with all X toolkits as far as I know. On Windows it's possible for the OS, or things like opening a modal dialog, to steal the capture, (there's an event for that when it happens too) so it's less of an issue.

Most people (including me) do run into this problem from time to time while in development, but it's not too catastrophic. What I usually do on Linux when this happens is switch to a virtual console (Ctrl-Alt-F1) and then kill the process that has the mouse captured, and then switch back to the virtual console containing the X-Server (usually Ctrl-Alt-F7)

Idea is to implement drag/drop and picking without interfacing each other.

THIS IS OPTIONAL
I did post about this earlier but not able to implement it. While
dragging, you should see a rectangle of some
size but with the color of source rectangle. This is to give a visual
hint about source color.

There are a couple ways to do this, although they behave a bit differently across platforms so you'll probably want to do some platform specific code for this.

When you create your wx.DropSource you can pass it the images to use for the drag cursors (Windows) or the drag icon (GTK).

The other option is that you can override the GiveFeedback method of the wx.DropSource class, and then do something in that method to show something in the UI for the DnD while it is happening.

···

On 6/8/10 10:25 AM, Prashant Saxena wrote:

--
Robin Dunn
Software Craftsman

Thanks,

The drag/drop problem is solved. Trick is working but I don't know if
4 pixel displacement is sufficient or I would be
needing more then that. So far it's working on ubuntu and fedora.

For drag image I did like this:
dropSource = wx.DropSource(self)
dropSource.SetCursor(5, wx.StockCursor(9))

Nothing is happening and didn't find much about "SetCursor" in docs,
specially about the first argument "result". If this is solved then
creating cursor using custom image will do the job.

Prashant