From 8099c16b57e4a863e87dc95ee7d55d0f23f778ba Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sat, 12 Dec 2015 00:50:59 +0100 Subject: [PATCH] Improve sub-sub-menu handling --- ChangeLog | 3 +++ src/fmenu.cpp | 11 +++++++---- test/menu.cpp | 4 ++-- test/ui.cpp | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c6ef11d..56d48858 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2015-12-12 Markus Gans + * Improve sub-sub-menu handling + 2015-12-10 Markus Gans * PC encoding: Avoid to print ASCII sign 0x00..0x1f in xterm * Newfont Bullet sign diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 7ba94c45..463973a8 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -180,7 +180,7 @@ void FMenu::menu_dimension() while ( iter != end ) { (*iter)->setGeometry (item_X, item_Y, int(maxItemWidth), 1); - + if ( (*iter)->hasMenu() ) {//(*iter)->setText( FString().setNumber(itemlist.size()) ); int menu_X = (*iter)->getGlobalX() + int(maxItemWidth); @@ -290,8 +290,8 @@ bool FMenu::containsMenuStructure (int x, int y) const if ( getGeometryGlobal().contains(x,y) ) return true; - else if ( si && si->hasMenu() ) - return si->getMenu()->getGeometryGlobal().contains(x,y); + else if ( si && si->hasMenu() && open_sub_menu ) + return si->getMenu()->containsMenuStructure(x,y); else if ( item && item->getGeometryGlobal().contains(x,y) ) return true; else @@ -1207,6 +1207,7 @@ void FMenu::onMouseMove (FMouseEvent* ev) setClickedWidget(open_sub_menu); open_sub_menu->onMouseMove(_ev); delete _ev; + return; } else if ( ! mouse_over_menu && mouse_over_supermenu ) { @@ -1219,6 +1220,7 @@ void FMenu::onMouseMove (FMouseEvent* ev) setClickedWidget(smenu); smenu->onMouseMove(_ev); delete _ev; + return; } else if ( mouse_over_menubar ) { @@ -1233,6 +1235,7 @@ void FMenu::onMouseMove (FMouseEvent* ev) mbar->mouse_down = true; mbar->onMouseMove(_ev); delete _ev; + return; } else if ( ! hasSelectedItem() && statusBar() && mouse_over_menu ) { @@ -1250,7 +1253,7 @@ void FMenu::onMouseMove (FMouseEvent* ev) if ( focus_changed ) redraw(); - + if ( show_sub_menu ) { // close open sub menu diff --git a/test/menu.cpp b/test/menu.cpp index 5efcefe5..29726ee1 100644 --- a/test/menu.cpp +++ b/test/menu.cpp @@ -199,12 +199,12 @@ Menu::Menu (FWidget* parent) Headline1->ignorePadding(); Headline1->setGeometry(3,2,5,1); Headline1->setEmphasis(); - + FLabel* Headline2 = new FLabel(" Function ", this); Headline2->ignorePadding(); Headline2->setGeometry(15,2,10,1); Headline2->setEmphasis(); - + // Info label FLabel* Info = new FLabel(" Activate menu bar\n" "+ Exit", this); diff --git a/test/ui.cpp b/test/ui.cpp index 8ba2bda1..b29a6d12 100644 --- a/test/ui.cpp +++ b/test/ui.cpp @@ -720,7 +720,7 @@ void MyDialog::cb_view (FWidget*, void* data_ptr) { FString file; FMenuItem* item = static_cast(data_ptr); - + if ( item && item->getText() ) file = item->getText(); else