Correctly enable shortcuts before opening a popup menu, and disable them after closing it.

[GB.GTK]
* BUG: Correctly enable shortcuts before opening a popup menu, and disable them after closing it.

[GB.GTK3]
* BUG: Correctly enable shortcuts before opening a popup menu, and disable them after closing it.

[GB.QT4]
* BUG: Correctly enable shortcuts before opening a popup menu, and disable them after closing it.

[GB.QT5]
* BUG: Correctly enable shortcuts before opening a popup menu, and disable them after closing it.
This commit is contained in:
Benoît Minisini 2023-06-14 00:51:31 +02:00
parent eb6b84667a
commit cc74743dab
3 changed files with 25 additions and 27 deletions

View file

@ -669,7 +669,7 @@ bool gMenu::isFullyEnabled() const
if (menu->_exec) if (menu->_exec)
return true; return true;
if (!menu->isEnabled()) if (!menu->isEnabled() || !menu->isVisible())
return false; return false;
if (menu->isTopLevel()) if (menu->isTopLevel())
@ -694,7 +694,7 @@ void gMenu::updateShortcut()
_shortcut_key = 0; _shortcut_key = 0;
} }
if (isFullyEnabled() && _shortcut) if (isVisible() && isFullyEnabled() && _shortcut)
{ {
gt_shortcut_parse(_shortcut, &_shortcut_key, &_shortcut_mods); gt_shortcut_parse(_shortcut, &_shortcut_key, &_shortcut_mods);
if (_shortcut_key) if (_shortcut_key)
@ -710,8 +710,8 @@ void gMenu::updateShortcutRecursive()
gMenu *ch; gMenu *ch;
int i; int i;
if (_exec) /*if (_exec)
return; return;*/
updateShortcut(); updateShortcut();
@ -735,7 +735,7 @@ void gMenu::setText(const char *text)
update(); update();
} }
bool gMenu::isVisible() bool gMenu::isVisible() const
{ {
if (!menu) return false; if (!menu) return false;
return _visible; return _visible;
@ -751,6 +751,7 @@ void gMenu::updateVisible()
//fprintf(stderr, "gMenu::updateVisible: %s '%s' %d\n", name(), text(), vl); //fprintf(stderr, "gMenu::updateVisible: %s '%s' %d\n", name(), text(), vl);
gtk_widget_set_visible(GTK_WIDGET(menu), vl); gtk_widget_set_visible(GTK_WIDGET(menu), vl);
updateShortcutRecursive();
//g_object_set(G_OBJECT(menu),"visible",vl,(void *)NULL); //g_object_set(G_OBJECT(menu),"visible",vl,(void *)NULL);
if (_toplevel && pr) if (_toplevel && pr)
@ -857,6 +858,7 @@ void gMenu::doPopup(bool move, int x, int y)
_in_popup++; _in_popup++;
_popup_count++; _popup_count++;
_exec = true; _exec = true;
updateShortcutRecursive();
#if GTK_CHECK_VERSION(3, 22, 0) #if GTK_CHECK_VERSION(3, 22, 0)
@ -926,6 +928,7 @@ void gMenu::doPopup(bool move, int x, int y)
MAIN_do_iteration(false); MAIN_do_iteration(false);
_exec = false; _exec = false;
updateShortcutRecursive();
_current_popup = save_current_popup; _current_popup = save_current_popup;
gApplication::_popup_grab = save_grab; gApplication::_popup_grab = save_grab;

View file

@ -54,7 +54,7 @@ public:
int childCount() const; int childCount() const;
char* shortcut() const { return _shortcut; } char* shortcut() const { return _shortcut; }
char* text() const { return _text; } char* text() const { return _text; }
bool isVisible(); bool isVisible() const;
gPicture* picture() const { return _picture; } gPicture* picture() const { return _picture; }
gMainWindow* window(); gMainWindow* window();
char *name() const { return _name; } char *name() const { return _name; }

View file

@ -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) static void delete_menu(CMENU *_object)
{ {
if (THIS->deleted) if (THIS->deleted)
@ -245,7 +237,7 @@ static bool is_fully_enabled(CMENU *_object)
if (THIS->exec) if (THIS->exec)
return true; return true;
if (THIS->disabled) if (THIS->disabled || !THIS->visible)
return false; return false;
if (CMENU_is_toplevel(THIS)) if (CMENU_is_toplevel(THIS))
@ -276,8 +268,8 @@ static void update_accel(CMENU *_object)
static void update_accel_recursive(CMENU *_object) static void update_accel_recursive(CMENU *_object)
{ {
if (THIS->exec) /*if (THIS->exec)
return; return;*/
update_accel(THIS); 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) static void update_check(CMENU *_object)
{ {
if (THIS->checked || THIS->toggle || THIS->radio) if (THIS->checked || THIS->toggle || THIS->radio)
@ -761,26 +761,21 @@ END_METHOD
void CMENU_popup(CMENU *_object, const QPoint &pos) void CMENU_popup(CMENU *_object, const QPoint &pos)
{ {
bool disabled;
void *save; void *save;
HANDLE_PROXY(_object); HANDLE_PROXY(_object);
if (THIS->menu && !THIS->exec) 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); //qDebug("CMENU_popup: %p: open", THIS);
// The Click event is posted, it does not occur immediately. // The Click event is posted, it does not occur immediately.
save = CWIDGET_enter_popup(); save = CWIDGET_enter_popup();
THIS->exec = true; THIS->exec = true;
update_accel_recursive(THIS);
//update_accel_recursive(THIS);
_popup_immediate = true; _popup_immediate = true;
THIS->menu->exec(pos); THIS->menu->exec(pos);
_popup_immediate = false; _popup_immediate = false;