diff --git a/gb.gtk/src/gmenu.cpp b/gb.gtk/src/gmenu.cpp index 55fca49e9..6e67d5510 100644 --- a/gb.gtk/src/gmenu.cpp +++ b/gb.gtk/src/gmenu.cpp @@ -669,7 +669,7 @@ bool gMenu::isFullyEnabled() const if (menu->_exec) return true; - if (!menu->isEnabled()) + if (!menu->isEnabled() || !menu->isVisible()) return false; if (menu->isTopLevel()) @@ -694,7 +694,7 @@ void gMenu::updateShortcut() _shortcut_key = 0; } - if (isFullyEnabled() && _shortcut) + if (isVisible() && isFullyEnabled() && _shortcut) { gt_shortcut_parse(_shortcut, &_shortcut_key, &_shortcut_mods); if (_shortcut_key) @@ -710,8 +710,8 @@ void gMenu::updateShortcutRecursive() gMenu *ch; int i; - if (_exec) - return; + /*if (_exec) + return;*/ updateShortcut(); @@ -735,7 +735,7 @@ void gMenu::setText(const char *text) update(); } -bool gMenu::isVisible() +bool gMenu::isVisible() const { if (!menu) return false; return _visible; @@ -751,6 +751,7 @@ void gMenu::updateVisible() //fprintf(stderr, "gMenu::updateVisible: %s '%s' %d\n", name(), text(), vl); gtk_widget_set_visible(GTK_WIDGET(menu), vl); + updateShortcutRecursive(); //g_object_set(G_OBJECT(menu),"visible",vl,(void *)NULL); if (_toplevel && pr) @@ -857,7 +858,8 @@ void gMenu::doPopup(bool move, int x, int y) _in_popup++; _popup_count++; _exec = true; - + updateShortcutRecursive(); + #if GTK_CHECK_VERSION(3, 22, 0) GdkWindow *win; @@ -926,6 +928,7 @@ void gMenu::doPopup(bool move, int x, int y) MAIN_do_iteration(false); _exec = false; + updateShortcutRecursive(); _current_popup = save_current_popup; gApplication::_popup_grab = save_grab; diff --git a/gb.gtk/src/gmenu.h b/gb.gtk/src/gmenu.h index 10eccc89f..60c1fc8fa 100644 --- a/gb.gtk/src/gmenu.h +++ b/gb.gtk/src/gmenu.h @@ -54,7 +54,7 @@ public: int childCount() const; char* shortcut() const { return _shortcut; } char* text() const { return _text; } - bool isVisible(); + bool isVisible() const; gPicture* picture() const { return _picture; } gMainWindow* window(); char *name() const { return _name; } diff --git a/gb.qt4/src/CMenu.cpp b/gb.qt4/src/CMenu.cpp index 5b6dcfff8..b2f90af23 100644 --- a/gb.qt4/src/CMenu.cpp +++ b/gb.qt4/src/CMenu.cpp @@ -170,14 +170,6 @@ static void unregister_menu(CMENU *_object) } } -static void set_menu_visible(void *_object, bool v) -{ - THIS->visible = v; - ACTION->setVisible(v); - refresh_menubar(THIS); - //update_accel_recursive(THIS); -} - static void delete_menu(CMENU *_object) { if (THIS->deleted) @@ -245,7 +237,7 @@ static bool is_fully_enabled(CMENU *_object) if (THIS->exec) return true; - if (THIS->disabled) + if (THIS->disabled || !THIS->visible) return false; if (CMENU_is_toplevel(THIS)) @@ -276,8 +268,8 @@ static void update_accel(CMENU *_object) static void update_accel_recursive(CMENU *_object) { - if (THIS->exec) - return; + /*if (THIS->exec) + return;*/ update_accel(THIS); @@ -290,6 +282,14 @@ static void update_accel_recursive(CMENU *_object) } } +static void set_menu_visible(void *_object, bool v) +{ + THIS->visible = v; + ACTION->setVisible(v); + refresh_menubar(THIS); + update_accel_recursive(THIS); +} + static void update_check(CMENU *_object) { if (THIS->checked || THIS->toggle || THIS->radio) @@ -761,26 +761,21 @@ END_METHOD void CMENU_popup(CMENU *_object, const QPoint &pos) { - bool disabled; void *save; HANDLE_PROXY(_object); if (THIS->menu && !THIS->exec) { - disabled = THIS->disabled; - if (disabled) - { - THIS->disabled = false; - update_accel_recursive(THIS); - THIS->disabled = true; - } - //qDebug("CMENU_popup: %p: open", THIS); // The Click event is posted, it does not occur immediately. save = CWIDGET_enter_popup(); THIS->exec = true; + + update_accel_recursive(THIS); + + //update_accel_recursive(THIS); _popup_immediate = true; THIS->menu->exec(pos); _popup_immediate = false;