My GUI is made up of views/layers. Like, I might have a view for the main menu and one for the credits.
Each view has widgets.
Now, I've found it necessary to have a "pre" call for any mouse input event and a normal call. For example, I might call prelbuttondown (left mouse button down) on all the views, which propagates to all their widgets.
The reason is that if I have a dropdown list selector that covers up a widget (let's say a button) that comes after it, the input event will first get intercepted by the button covered up by the dropdown menu. The widgets input methods are called in reverse order, since the last one will be drawn last and be on top of the other ones.
This also applies to drawing. I have a draw() method and a draw2() method that is called after all the draw() methods because even though the dropdown list is drawn before the button, it might have a dropdown menu opened that will cover up other widgets.
I was told I should have a variable that keeps track of the active widget. That way I can check the active widget for input event interception first. And I suppose I could call an overdraw() method on the active widget for any drawing that has to be done on top of the other widgets.
But this brings more headache; I only propagate events to views that are open and there's no way to get the view that a widget belongs to, and a widgets can have whole hierarchies of subwidgets. Also, if I have only one active widget with an overdraw() method being called, how do I do label text that appears when the mouse hovers over a button?
Is there an easy solution? What is the correct way to do this?