Hi,
The issue is that by the time you check, another event was sent.
The solution is to defer the event using "next frame event". I would add next frame event on non critical events such as the one emerging from a UI setup, so before you decide to implement a next frame event, make sure you know both events that are in conflict and take some time to think about the best way to add a frame delay, which one would be more likely to be fine with a delay basically.
I do that very often, especially as your UI and content gets more and more interlinked, you end up often with loops between content and UI so that both are refreshed and reflect the proper application state, on these scenario, having a proper delay sequence is essential. I sometimes even use IOS event system paradigm where I will send an event saying "GOING TO DO THIS" then and event "I AM DOING THIS" and then and event "I HAVE DONE THIS", which lets everything else catch up, and act properly on what's going to happen. A
frame delay between these 3 phase of an action is helpful. The added benefit is that you can have another part of your app interfere and cancel THIS or else do something before THIS is done, etc etc.
If that doesn't help, can you explain in details the event you are sending and the one that gets detected instead?
Bye,
Jean