In 1.3.1, I had code like this to check if the GUI wanted the event or not:
Code: Select all
if (disableEvents) return false; // guard against infloops
// ... switch() etc for other event types
bool wasDisabled = disableEvents;
disableEvents = true; // prevent nasty recursion from GUI
bool guiEvent = ctx->guienv->postEventFromUser(event);
disableEvents = wasDisabled;
if (guiEvent) return true; // gui wanted it
// .. do my scene node picking stuff
This code worked in 1.3.1. In 1.4beta, I find that EGET_MENU_ITEM_SELECTED is being handled (not just generated, but handled = dispatched to my event handler) from within the postEventFromUser() call, and thus was getting dropped by my recursive event guard (in 1.3.1, postEventFromUser would return after generating the event, but before dispatching it, thus I could re-enable events and the menu select event would get processed). Fixing it was no big deal, I just special cased the menu select event (I didn't want to move the disableEvent code because then I could end up with multiple "guards" like that all over the place) but figuring out that was what was happening did take some time. And I don't like having the special case there, since who knows what else might be getting dispatched from within postEventFromUser() that I drop by accident.
If you followed this discussion so far, and the issues, my question is this: what is the "right" way to delegate events to the GUI?