diff --git a/bazaar/XMLMenu/WithXMLMenu.h b/bazaar/XMLMenu/WithXMLMenu.h index 5a95f636d..90353807a 100644 --- a/bazaar/XMLMenu/WithXMLMenu.h +++ b/bazaar/XMLMenu/WithXMLMenu.h @@ -42,6 +42,10 @@ template class WithXMLMenu : public T, public XMLMenuInterface // or docking points changed void RefreshFrames(void); + // use ctrl+click to undock toolbars + // to avoid undocking when missing toolbar icon + bool ctrlToUndock; + // dragging flag bool dragging; @@ -164,6 +168,9 @@ template WithXMLMenu::WithXMLMenu() : RefreshFrames(); + // by default, force usage of ctrl to undock toolbars + ctrlToUndock = true; + } template WithXMLMenu::~WithXMLMenu() @@ -283,6 +290,11 @@ template void WithXMLMenu::ChildFrameMouseEvent(Ctrl *child, int eve if(event != Ctrl::LEFTDOWN) return; + // if we choose to undock only with pressed CTRL key + // check it + if(ctrlToUndock && !(keyflags & K_CTRL)) + return; + // ignore re-entrant events if(dragging) return; @@ -716,12 +728,19 @@ template void WithXMLMenu::Xmlize(XmlIO xml) ("commands" , commands) ("menubars" , menuBars) ("toolbars" , toolBars) + ("CtrlToUndock" , ctrlToUndock) ; // here too, we use postcallback because we must // wait that top window is opened before refreshing toolbars // don't know if it's the right way, but..... if(xml.IsLoading()) + { + // backwards compatibility + if(IsNull(ctrlToUndock)) + ctrlToUndock = true; + T::PostCallback(THISBACK(RefreshBarsDeep)); + } } // toggles bar visibility @@ -758,6 +777,9 @@ template void WithXMLMenu::XMLContextMenu(Bar& bar) if(!toolBars.GetCount()) return; bar.Separator(); + Bar::Item &item = bar.Add(t_("Ctrl+Click to undock"), [&]() { ctrlToUndock = !ctrlToUndock; }); + item.Check(ctrlToUndock); + bar.Separator(); for(int iBar = 0; iBar < toolBars.GetCount(); iBar++) { XMLToolBarCtrl &toolBarCtrl = toolBarCtrls[iBar];