itsalamanca
09-05-2009 11:50:19
hi, i am having some troubles with the meu popup.
I have created a menu bar and i can select some items in a popup menu. These elements call to other panels or windows.When i come back to the menu, i clic to open de popup menu but it only is showed 1 second and then disappear.
Some body can tell me what it's happens.
thanks.
Altren
09-05-2009 16:03:24
Show your code: how you create it and what you do. Or look how menu bar used in LayoutEditor code.
itsalamanca
09-05-2009 23:24:25
the layout of the menu:
<Widget type="Widget" skin="Panel" position="0 0 912 652" layer="Back" name="panel_nuevo">
<Widget type="MenuBar" skin="MenuBar" position="0 0 1438 26" align="HStretch Top" layer="Overlapped" name="MenuRobot">
<Widget type="MenuItem" skin="MenuBarButton" position="0 0 60 22">
<Property key="Widget_Caption" value="Herramientas"/>
<Property key="MenuItem_Type" value="Popup"/>
<Property key="MenuItem_Id" value="herram"/>
<Widget type="PopupMenu" skin="PopupMenu" position="0 0 88 68" style="Popup" layer="Popup">
<Widget type="MenuItem" skin="PopupMenuLine" position="0 0 80 20">
<Property key="Widget_Caption" value="Anadir"/>
<Property key="MenuItem_Id" value="Anadir"/>
</Widget>
<Widget type="MenuItem" skin="PopupMenuLine" position="0 20 80 20">
<Property key="Widget_Caption" value="Guardar"/>
<Property key="MenuItem_Id" value="Guardar"/>
</Widget>
<Widget type="MenuItem" skin="PopupMenuLine" position="0 40 80 20">
<Property key="Widget_Caption" value="Configurar"/>
<Property key="MenuItem_Id" value="Configurar"/>
</Widget>
<Widget type="MenuItem" skin="PopupMenuLine" position="0 60 80 20">
<Property key="Widget_Caption" value="Salir"/>
<Property key="MenuItem_Id" value="Salir"/>
</Widget>
</Widget>
</Widget>
<Widget type="MenuItem" skin="MenuBarButton">
<Property key="Widget_Caption" value="Ayuda"/>
<Property key="MenuItem_Type" value="Popup"/>
<Property key="MenuItem_Id" value="ayudaR"/>
<Widget type="PopupMenu" skin="PopupMenu" style="Popup" layer="Popup">
<Widget type="MenuItem" skin="PopupMenuLine">
<Property key="Widget_Caption" value="Acerca De"/>
<Property key="MenuItem_Id" value="AcercadeR"/>
</Widget>
<Widget type="MenuItem" skin="PopupMenuLine">
<Property key="Widget_Caption" value="Ayuda en Linea"/>
<Property key="MenuItem_Id" value="AyudalineaR"/>
</Widget>
</Widget>
</Widget>
</Widget>
and the code:
try
{
MyGUI::LayoutManager::getInstance().load("panelMenuPantallaInicio.layout");
//MYGUI_ASSERT(menu_items.size() == 1, "Error load main menu"); //para los errores.
MyGUI::MenuBarPtr menuBar = MyGUI::Gui::getInstance().findWidget<MyGUI::MenuBar>("Menu");
MyGUI::MenuItemPtr menuArchivo = menuBar->getItemById("archivo");
mPopupMenuArchivo = menuArchivo->getItemChild();
MyGUI::MenuItemPtr menuItemConfigurar = mPopupMenuArchivo->getItemById("configurar");
MyGUI::MenuItemPtr menuItemSalir = mPopupMenuArchivo->getItemById("salir");
MyGUI::MenuItemPtr menuAyuda = menuBar->getItemById("ayuda");
mPopupMenuAyuda = menuAyuda->getItemChild();
menuBar->eventMenuCtrlAccept = newDelegate(this, &InterfazMenu::manejadorMenuArchivo);
}
catch(MyGUI::MyGUIException &e)
{
MessageBox( NULL,"Fallo inicializando los menus de la pantalla de inicio.", "Un error ha ocurrido!",
MB_OK | MB_ICONERROR | MB_TASKMODAL);
}
}
void manejadorMenuArchivo(MyGUI::MenuCtrlPtr _sender, MyGUI::MenuItemPtr _item)
{
try
{
if (mPopupMenuArchivo == _item->getMenuCtrlParent())
{
std::string id = _item->getItemId();
if (id == "nuevo")
{
mEscena=new ManejadorEscena(theListener,gSceneMgr,gSceneMgrAux,gCamera, gCameraAux);
MyGUI::WidgetPtr panelinicio=MyGUI::Gui::getInstance().findWidget<MyGUI::Widget>("pantallaInicio");
panelinicio->setVisible(false);
panelinicio->setEnabled(false);
robot=new Robot(mEscena);
InterfazRobotNuevo *interfazRobotNuevo;
if((interfazRobotNuevo=new InterfazRobotNuevo(gRoot,robot, gSceneMgr,gViewport, gSceneMgrAux, gCamera, gCameraAux,theListener))==NULL)
MessageBox( NULL,"Fallo instanciando InterfazRobotNuevo", "Un error ha ocurrido!",MB_OK | MB_ICONERROR | MB_TASKMODAL);
}
else if (id == "cargar")
{
MyGUI::WidgetPtr panelinicio=MyGUI::Gui::getInstance().findWidget<MyGUI::Widget>("pantallaInicio");
panelinicio->setVisible(false);
panelinicio->setEnabled(false);
mEscena=new ManejadorEscena(theListener,gSceneMgrAux,gCameraAux,0); //la creo aqui y se la paso a la otra clase para usarla tb.
robot=new Robot(mEscena);
InterfazRobotCargado *interfazRobotCargado;
if((interfazRobotCargado=new InterfazRobotCargado(gRoot,robot, gSceneMgr,gViewport, gSceneMgrAux, gCamera, gCameraAux, theListener))==NULL)
MessageBox( NULL,"Fallo instanciando InterfazRobotCargado", "Un error ha ocurrido!",MB_OK | MB_ICONERROR | MB_TASKMODAL);
}
else if (id == "configurar")
{
// MyGUI::LayoutManager::getInstance().load("multilista.layout");
// MyGUI::ListaPtr multilista=MyGUI::Gui::getInstance().findWidget<MyGUI::Lista>("multilista");
configurarAplicacion(); //de momento no tiene mucho sentido.
}
else if (id == "salir") {
theListener->cerrarDesdeFuera(); //con esto finalizo el loop de renderizacion del listener.
}
}
else
{
if(mPopupMenuAyuda==_item->getMenuCtrlParent())
{
std::string id = _item->getItemId();
if(id=="Acercade")
{
AcercaDe();
}
if(id=="Ayudalinea")
{
//aqui puede ser lo ver la idea de tenerlo abierto, o por debajo, de alguna manera.
InterfazAyuda *interfazAyuda=new InterfazAyuda(); //luego hacer en una clase.
}
}
}
}catch(MyGUI::MyGUIException &e)
{
MessageBox( NULL,"Fallo eligiendo opciĆ³n de menu.", "Un error ha ocurrido!",
MB_OK | MB_ICONERROR | MB_TASKMODAL);
}
}
itsalamanca
11-05-2009 07:41:13
hi again,
I am trying to explain better my problem. When a push the menu option i load another panel. Then i go back to the main panel and theni try to push again the same option in the same popup menu. The menu popun is opened for a second and then dissapear, i can't select any option.
the problem is solved when i make some clic on another point of the panel. Then i can select my menu option. But this is not good for the usability of the application.
thanks
plazagudo
17-05-2009 23:40:36
something similar happens to me. I think that it is a mygui mistake.
Altren
18-05-2009 18:32:19
Can you show something that works bad - some layout or code that creates your menubar?
2 itsalamanca Code and layout that you posted looks like something weird. It's absolutely unrelated code because in layout all id's 1st letters is capital and in code - no. You also tries to fing some "Menu" widget that is no listed in layout.