in a canvas, I have the MouseDown event returning true. Yet, if I drag the mouse outside the canvas area and release it, the action in MouseUp fires.
- MouseDown: Return True
- MouseUp: beep
- Dragging the mouse outside the object and releasing it I get the beep.
If this behavior is wrong, is there a workaround to it? Thanks.
Both with Mac (Sierra) and Windows 10.
I do not believe that is wrong.
I just wrote a control the needed to check this… what I did was set a flag in MouseDown
then reset it if MouseExit occurred before MouseUP
In mouseup, if the flag was false I just ignored the up event
Thank you Dave, I’ll apply your suggestion.
Yet LR for Canvas > MouseDown says:
[quote]The coordinates x and y are local to the control, i.e. they represent the position of the mouse click relative to the upper-left corner or the Control.
Return True if you are going to handle the MouseDown. In such a case:
The Action event, if any, will not execute and the state of the object will not change.
You will receive the MouseDrag and MouseUp events.[/quote]
It always worked this way and I feel this is the correct handling.
And the LR clearly states
You will receive the MouseDrag and MouseUp events.
This seems right. From the LR: “The mouse button was released. Use the x and y parameters to determine if the mouse button was released within the control’s boundaries.” The event handling gives you the freedom to do with it what you wish.
Dave’s approach seems like a good way to code for what you desire. Some other application may want to handle clicking and dragging differently (e.g. dragging an object or a drawing program).
Thanks for the clarification. I was coming from a seemingly inconsistent behaviour of being used to pressing a button erroneously, then moving out of the button, and releasing the mouse without ill effect.
But it is the RETURN TRUE that makes all the difference.
It is also normal to drag to outside the canvas in a drawing app (for example to make a partially visible object) and then release the mouse, so I should better have thought of this example.
Yes, I too thank you for the clarification.