Merge pull request #2198 from Areloch/MenuBarMoreFixup

Fixes up some menubar issues.
This commit is contained in:
Areloch 2018-02-13 14:55:49 -06:00 committed by GitHub
commit cd5b0a0612
3 changed files with 19 additions and 10 deletions

View file

@ -133,7 +133,8 @@ GuiCanvas::GuiCanvas(): GuiControl(),
mLastRenderMs(0), mLastRenderMs(0),
mPlatformWindow(NULL), mPlatformWindow(NULL),
mDisplayWindow(true), mDisplayWindow(true),
mMenuBarCtrl(NULL) mMenuBarCtrl(nullptr),
mMenuBackground(nullptr)
{ {
setBounds(0, 0, 640, 480); setBounds(0, 0, 640, 480);
mAwake = true; mAwake = true;
@ -296,8 +297,11 @@ void GuiCanvas::setMenuBar(SimObject *obj)
mMenuBarCtrl = dynamic_cast<GuiControl*>(obj); mMenuBarCtrl = dynamic_cast<GuiControl*>(obj);
//remove old menubar //remove old menubar
if( oldMenuBar ) if (oldMenuBar)
Parent::removeObject( oldMenuBar ); {
Parent::removeObject(oldMenuBar);
Parent::removeObject(mMenuBackground); //also remove the modeless wrapper
}
// set new menubar // set new menubar
if (mMenuBarCtrl) if (mMenuBarCtrl)
@ -312,14 +316,17 @@ void GuiCanvas::setMenuBar(SimObject *obj)
return; return;
} }
GuiControl* menuBackground = new GuiControl(); if (mMenuBackground == nullptr)
menuBackground->registerObject(); {
mMenuBackground = new GuiControl();
mMenuBackground->registerObject();
menuBackground->setControlProfile(profile); mMenuBackground->setControlProfile(profile);
}
menuBackground->addObject(mMenuBarCtrl); mMenuBackground->addObject(mMenuBarCtrl);
Parent::addObject(menuBackground); Parent::addObject(mMenuBackground);
} }
// update window accelerator keys // update window accelerator keys

View file

@ -198,6 +198,7 @@ protected:
static CanvasSizeChangeSignal smCanvasSizeChangeSignal; static CanvasSizeChangeSignal smCanvasSizeChangeSignal;
GuiControl *mMenuBarCtrl; GuiControl *mMenuBarCtrl;
GuiControl* mMenuBackground;
public: public:
DECLARE_CONOBJECT(GuiCanvas); DECLARE_CONOBJECT(GuiCanvas);

View file

@ -1519,9 +1519,10 @@ DefineConsoleMethod(GuiMenuBar, insert, void, (SimObject* pObject, S32 pos), (nu
object->insert(pObject, pos); object->insert(pObject, pos);
} }
DefineConsoleMethod(GuiMenuBar, findMenu, S32, (StringTableEntry barTitle), (""), "(barTitle)") DefineConsoleMethod(GuiMenuBar, findMenu, S32, (const char* barTitle), (""), "(barTitle)")
{ {
PopupMenu* menu = object->findMenu(barTitle); StringTableEntry barTitleStr = StringTable->insert(barTitle);
PopupMenu* menu = object->findMenu(barTitleStr);
if (menu) if (menu)
return menu->getId(); return menu->getId();