Consider the following rules:
- I have a
drawin
of let's say width=200, height=200. - Inside of this
drawin
I have an element which has width=10 height=10 - I want to be able to click ("button::press") and drag ("mouse::move") this element.
- When I release ("button::release) the mouse button, I want the element to no longer be dragged when I move the mouse.
With these rules in mind, I do the following:
- I click on the element.
- I drag the mouse to somewhere out of the
drawin
. - I release the click button.
- I move my mouse back into the
drawin
. - The element still moves, because no "button::release" event was emitted on the
drawin
. Also, If I move my mouse quickly enough outside thedrawin
, the element will NOT be on the edge of thedrawin
.
The expected result would be that the element would be dragged to the edge of the drawin for as long as I hold down the mouse button, and that the element would stop being dragged when I release the mouse button, wherever it may be on the screen.
My solution was that whenever I have some element which can be click-and-dragged, listen to "mouse::move" and "button::release" signals emitted by the global mouse
object, and go from there. The problem is that the global mouse
object does NOT emit these signals.
How can I fix this problem?