Buttons and WidgetEventArgs
I have some buttons and a handler for QuickGUI::Widget::EVENT_MOUSE_BUTTON_DOWN events. But in the handler QuickGUI::WidgetEventArgs::widget always points to a window, not to the button that was clicked. Am I doing something wrong here or is this a QuickGUI bug?
That's odd. Since the handler is being called, I'm assuming the button instance is calling Widget::fireEvent, which should be populating the WidgetEventArgs properly. Easiest way to track this it to break into GUIManager::injectMouseButtonDown(...) and step into the fireEvent function to see how the args are populated.
I didn't have the time to do any debugging so far. But I just noticed something. QuickGUI::WidgetEventArgs::widget is set to the active widget. So when clicking the button, it won't become the active widget. This is very similar to the problem with the TextBox (the one in my console), where the input TextBox too isn't becoming the active widget, when clicking on it. So it is probably the same bug in both cases.
That would mean that QuickGUI::GUIManager::mWidgetContainingMouse is sometimes holding the wrong value. Not sure yet what this is supposed to tell me ...
Edit: Found the cause of the problem. I am calling setGainFocusOnClick (false) on the sheet at the very beginning (before any other widget is created). If I remove this call, both bugs disappear. I know we had a discussion about it, but I don't remember the outcome (too long ago). Calling setGainFocusOnClick on a sheet is legal, right? So it should work without the "side-effects".
I can guess the problem:
setGainFocusOnClick is an inheritted property, all children will have the same value for this. When clicking on a widget, the recorded active widget is probably used in the WidgetEventArgs. If this is the case, it could be fixed by using the mWidgetContainingMouse instead of the mActiveWidget variable.
Also, I'm making the assumption that child widgets should inherit setGainFocusOnClick, this is desired right? For example, setting a Window's setGainFocusOnClick to false probably means you also don't want any children of this window to hold focus either.
Also, I'm making the assumption that child widgets should inherit setGainFocusOnClick, this is desired right?
I guess so. But not for sheets. To recap the situation: I consider only those areas of the window a part of the GUI, which actually show a visible widget. The other areas are not GUI, but world (the Ogre scene) and clicking on them should not influence the GUI.
Well I would think you do want this property set to false for the sheet. It sounds like you want to disable the sheet from receiving focus or input, since it's invisible and has no user defined purpose. In either case, you can always explicitly state whether a widget should receive focus on click, which overrides default behavior. I'll look into this and see if its an obvious problem.