querry43
29-07-2008 03:07:48
I would like to describe menus entirely from xml, but I'm not sure how to setup the popup menu items. Digging through the code, I wasn't able to find a way to do this. Is this currently possible? Is it planned?
Here is my working example which programmatically creates popup menu items:
Thanks.
PS: How do I get the menu item to de-select after I have triggered an eventPopupMenuAccept?
Here is my working example which programmatically creates popup menu items:
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="MenuBar" skin="MenuBar" position="0 0 800 20" align="ALIGN_LEFT ALIGN_HSTRETCH" layer="Main" name="Menu" >
<Property key="MenuBar_AddItem" value="File" />
<Property key="MenuBar_AddItem" value="Edit" />
</Widget>
</MyGUI>
void initialize()
{
...
MyGUI::MenuBarPtr menuBar = mGUI->findWidget<MyGUI::MenuBar>("Menu");
menuBar->getItemMenu(0)->addItem("Quit");
menuBar->getItemMenu(0)->eventPopupMenuAccept = MyGUI::newDelegate(this, &TerrainFrameListener::handleMenu);
...
}
void handleMenu(MyGUI::WidgetPtr _sender, size_t index)
{
switch(index)
{
case 0:
this->exit = true;
break;
}
}
Thanks.
PS: How do I get the menu item to de-select after I have triggered an eventPopupMenuAccept?