diff --git a/src/app/ui/toolbar.cpp b/src/app/ui/toolbar.cpp index add4dbb3e..733d9f325 100644 --- a/src/app/ui/toolbar.cpp +++ b/src/app/ui/toolbar.cpp @@ -94,6 +94,7 @@ ToolBar::ToolBar() : Widget(kGenericWidget) , m_tipTimer(300, this) , m_closeSlot(NULL) + , m_openedRecently(false) { m_instance = this; @@ -199,9 +200,9 @@ bool ToolBar::onProcessMessage(Message* msg) new_hot_tool = tool; new_hot_index = c; - if ((m_openOnHot) && (m_hotTool != new_hot_tool)) + if ((m_openOnHot) && (m_hotTool != new_hot_tool) && hasCapture()) { openPopupWindow(c, tool_group); - + } break; } } @@ -264,6 +265,12 @@ bool ToolBar::onProcessMessage(Message* msg) if (!hasCapture()) break; + if (!m_openedRecently) { + if (m_popupWindow && m_popupWindow->isVisible()) + m_popupWindow->closeWindow(this); + } + m_openedRecently = false; + releaseMouse(); // fallthrough @@ -440,6 +447,7 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group) // In case this tool contains more than just one tool, show the popup window m_popupWindow = new PopupWindow("", PopupWindow::kCloseOnClickOutsideHotRegion); m_closeSlot = m_popupWindow->Close.connect(Bind(&ToolBar::onClosePopup, this)); + m_openedRecently = true; ToolStrip* toolstrip = new ToolStrip(tool_group, this); m_currentStrip = toolstrip; @@ -586,10 +594,6 @@ void ToolBar::closeTipWindow() m_tipWindow->closeWindow(NULL); delete m_tipWindow; m_tipWindow = NULL; - - // Flush kPaintMessage messages and send them - getManager()->flushRedraw(); - getManager()->dispatchMessages(); } } diff --git a/src/app/ui/toolbar.h b/src/app/ui/toolbar.h index bc9aa66b6..263d9d32c 100644 --- a/src/app/ui/toolbar.h +++ b/src/app/ui/toolbar.h @@ -84,6 +84,10 @@ namespace app { // True if the popup-window must be opened when a tool-button is hot bool m_openOnHot; + // True if the last MouseDown opened the popup. This is used to + // close the popup with a second MouseUp event. + bool m_openedRecently; + // Window displayed to show a tool-group ui::PopupWindow* m_popupWindow; class ToolStrip;