I'm creating a gui api. I've run into a problem though that isn't easy to solve. Right now I use the following calls to receive messages :
I added functions for creating buttons and sliders etc...Code:gui_read_events(); //sees if there's a keyboard/mouse event and puts it in a list while (gui_get_event(*event)){ handleEvents(*event); } //copies the first element of the list and removes it from the list.
Everything works as it should, but after implenting timer events, I get a problem. When eg a togglebutton is pushed, I go into a subloop untill the mouse is released. In that subloop, I use gui_read_events() and gui_get_event(). I check if there's a MOUSE_UP event and if there is one, I exit the subloop. The problem is that timer events aren't sent to the user of the gui library anymore because his code can't be reached from the subloop. I've thought a little over this, but I can't find the ideal solution.
Should I redisign the whole system or is there an easier solution that doesn't require to much time recodeing everything ?
I hope I've made myself clear.