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:
parent
eb6b84667a
commit
cc74743dab
3 changed files with 25 additions and 27 deletions
|
@ -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,6 +858,7 @@ void gMenu::doPopup(bool move, int x, int y)
|
|||
_in_popup++;
|
||||
_popup_count++;
|
||||
_exec = true;
|
||||
updateShortcutRecursive();
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 22, 0)
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue