Don't block Menu::showPopup() with a customized event loop

We must call Menu::showPopup() in ui::kMouseUpMessage message.
This commit is contained in:
David Capello 2014-08-09 11:13:51 -03:00
parent 67f9354b3d
commit b1b4ed8b39
2 changed files with 10 additions and 8 deletions

View File

@ -273,16 +273,22 @@ bool Tabs::onProcessMessage(Message* msg)
return true; return true;
case kMouseDownMessage: case kMouseDownMessage:
case kMouseUpMessage:
if (m_hot != NULL) { if (m_hot != NULL) {
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
if (m_selected != m_hot) { if (m_selected != m_hot) {
m_selected = m_hot; m_selected = m_hot;
invalidate(); invalidate();
} }
if (m_selected && m_delegate) // Left button is processed in mouse down message, right
m_delegate->clickTab(this, // button is processed in mouse up.
m_selected->view, if (m_selected && m_delegate &&
static_cast<MouseMessage*>(msg)->buttons()); ((mouseMsg->left() && msg->type() == kMouseDownMessage) ||
(!mouseMsg->left() && msg->type() == kMouseUpMessage))) {
m_delegate->clickTab(this, m_selected->view, mouseMsg->buttons());
}
} }
return true; return true;

View File

@ -270,10 +270,6 @@ bool MenuItem::hasSubmenu() const
void Menu::showPopup(int x, int y) void Menu::showPopup(int x, int y)
{ {
do {
jmouse_poll();
} while (jmouse_b(0) != kButtonNone);
// New window and new menu-box // New window and new menu-box
Window* window = new Window(Window::WithoutTitleBar); Window* window = new Window(Window::WithoutTitleBar);
MenuBox* menubox = new MenuBox(); MenuBox* menubox = new MenuBox();