[FIXED] ComboBox and injectMousePress

NickDeath

17-02-2012 09:16:54

Updated to 3.2.0 and fixed some redundant code injecting events twice, this is no longer an issue.


MyGUI Version: 3.0.1
Ogre Version: 1.7.3
Currently, I have a Panel widget with a ComboBox widget inside it. I need the GUI to intercept the mouse press to prevent objects in the scene behind being deselected, so I need to inject the mouse press into the GUI system. But when I do, the ComboBox does not behave as expected.

If I inject the mouse press into the MyGUI system in my mousePressed function, the ComboBox popup does not work. The ComboBox is highlighted, and I can use arrow keys to make the options appear. The options respond to the mouse events fine.
If I do not inject the mouse press, then the ComboBox works as expected, with the drop down appearing when I click on the ComboBox, and its options respond to the mouse events fine.

Any and all help will be appreciated.

I currently use a layout file to create the elements:
<Widget type="Widget" skin="Panel" position="8 32 264 128" layer="Back" name="pnl_regioninfo">
<Widget type="StaticText" skin="StaticText" position="5 5 100 24" name="txt_owner_lbl">
<Property key="Widget_Caption" value="Owner:"/>
</Widget>
<Widget type="ComboBox" skin="ComboBox" position="100 5 100 26" name="sel_region_owner">
</Widget>
</Widget>


I have this in my code to set up the combobox:
MyGUI::ComboBox * combo = _gui->findWidget<MyGUI::ComboBox>("sel_region_owner");
combo->addItem("Player 1");
combo->addItem("Player 2");
combo->addItem("Neutral");
combo->setIndexSelected(0);
combo->setComboModeDrop(true);
combo->eventComboAccept = MyGUI::newDelegate(this, &EditorScreen::GUI_regioninfo_owner);


The mouse pressed function:
bool EditorScreen::mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id)
{
if (_gui->injectMousePress( evt.state.X.abs, evt.state.Y.abs, MyGUI::MouseButton::Enum(id)))
return true;
/* Non GUI code for mouse picking here*/
}