MouseUp, DropObject firing order

Hi
I’ve found an intermittent problem with my app. During drag and drop I find that MouseUp usually fires before DropObject, but occasionally, like one in 10 events, they fire around the other way. Of course that tends to mess things up a bit when one is dependent upon the results of the other.

Does anyone have any experience of this?

Jim

The only comment I have is that over the 14 years I have been using RB/RS/Xojo, I have repeatedly been advised not to depend on the order of event firings.

Yip, that sounds like a sensible solution. Enter Timer stage-left.

Trouble is I now have so many timers running to catch the right event order, that I’m not sure which order the timers are running in…

[quote=151507:@James Pitchford]Hi
I’ve found an intermittent problem with my app. During drag and drop I find that MouseUp usually fires before DropObject, but occasionally, like one in 10 events, they fire around the other way. Of course that tends to mess things up a bit when one is dependent upon the results of the other.

Does anyone have any experience of this?
[/quote]

Since the dropObject cannot take place without MouseUp having taken place, why not put all your code in there ?

The drop might not take place. You can have MouseUp without DropObject.

Yes, if the mouseUp takes place outside of the drop area. But that can be detected.

Or if they hit Escape to cancel the drag. Or…

This was precisely the problem - sometimes the dropObject would fire before the MouseUp - cannot explain why.
In the end I added a Timer to go off 10msec after the dropObject to ensure both events had taken place before doing the work. Seems to work fine at the moment.

Jim

There’s no requirement for a timer in this situation. Add a boolean property to the window named “bothDragEventsHappened”. In both the MouseUp and DropObject handlers, use this code:

if bothDragEventsHappened then
ProcessTheDragEvent //a window method that processes the drag
bothDragEventsHappened=false
else
bothDragEventsHappened=true
end

What happens when both events don’t fire and the flag doesn’t get reset?