diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 00e7899112..6ef1ee337e 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -1899,12 +1899,37 @@ glm::vec3 getGravity(glm::vec3 pos) { } } - +bool menuDisplayed = false; void mouseFunc(int button, int state, int x, int y) { - //catch mouse actions on the menu - bool menuClickedOrUnclicked = menu.mouseClick(x, y); + bool menuFound = menu.mouseClick(x, y); - if (!menuClickedOrUnclicked) { + // If we didn't previously have the menu displayed, and we did just click on the menu, then + // go into menuDisplayed mode.... + if (!::menuDisplayed && menuFound) { + ::menuDisplayed = true; + } + + // If the menu was displayed, and we're not over a menu, then leave menu mode + if (::menuDisplayed && !menuFound) { + ::menuDisplayed = false; + menu.hidePopupMenu(); + //menu.render(WIDTH,HEIGHT); // will hide the menu + } + + // In menu displayed mode use old logic + if (::menuDisplayed) { + if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN ) { + if (state == GLUT_DOWN && !menu.mouseClick(x, y)) { + mouseX = x; + mouseY = y; + mousePressed = 1; + } else if (state == GLUT_UP) { + mouseX = x; + mouseY = y; + mousePressed = 0; + } + } + } else { if (button == GLUT_LEFT_BUTTON) { mouseX = x; mouseY = y; diff --git a/interface/src/ui/Menu.h b/interface/src/ui/Menu.h index 7ffe93bb28..5ef2a6f11b 100644 --- a/interface/src/ui/Menu.h +++ b/interface/src/ui/Menu.h @@ -24,6 +24,7 @@ public: void render(int screenwidth, int screenheight); void renderColumn(int i); MenuColumn* addColumn(const char *columnName); + void hidePopupMenu() { currentColumn = -1; }; private: std::vector columns; int currentColumn;