I still believe you are making things much more complicated than they have to be.
If the callbacks are called and processed in your EventMethod for the GuiElementClickEvent before the same method closes the panel and its children then there should be no problem at all. I don't really understand why you think that would make the code unmanageable.
other options I can think of right now (the second is the best imo):
- add a 1-2 second timer (should be enough time for the other event to execute properly) before the Ok button's actions happen and the panel closes (i.e. put the whole contents of the method in a timer then start the timer in the method)
- make the Ok button save the information but not close the panel and have a second "x" button to close it, this way if I pressed Ok with a wrong value I have the chance to notice it and correct it, press Ok again and then close the panel myself when I am sure I am done
- tell the users to click somewhere else or press Return while in the text field before clicking the Ok button
it is possible, but I have described a very real and relatively frequent case where the current event order is "non-preferred". Can you describe a use case where, when the focus moves from element A to element B, it would be preferred to have the event for element B (the focus destination element) notified before the event for element A (the source element)?
I can't really think of a case right now as I haven't used that kind of thing before (I just put a save button to save the content of my 20 or so textfields and then close the panel with an "x" button on the top right as in Windows (Linux sometimes can have it on the top left instead)).
But my point was more a general one, shifting the problem is not really a solution.
PS: anyway now that I thought of it a bit more, the 2 events should trigger at the same time not one before the other anyway. As in when I click somewhere else the GuiInputEvent is executed and when I click on a clickable label the GuiElementClickEvent is executed so by clicking the label right after being in the text field should cause both events to execute simultaneously just like when I hit with a pickaxe while moving both the DestroyTerrain and the PlayerChangePosition Events should trigger at the same time not in some order.