accelerator set for buttons in GtkMenuButton isn't reliable
Accelerators set for GtkModelButton
s set as popover
for a GtkMenuButton
doesn't work reliably.
Say, a menu is set for the window with an accelerator F10
, and a menu item with accelerator F9
. The accelerator F10
always works when the window is focus. F9
accelerator works only when the menu is open (ie, the menu item is visible). Ideally it would be nice if the accelerators of menu items works from all contexts where the parent menu accelerator works.
A non-working example .ui code (GTK+4):
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="MgtWindow" parent="GtkApplicationWindow">
<property name="height-request">300</property>
<property name="width-request">400</property>
<!-- Headerbar -->
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="show-title-buttons">1</property>
<!-- Menu Button -->
<child>
<object class="GtkMenuButton" id="menu_button">
<property name="direction">none</property>
<property name="popover">main_menu</property>
<!-- THIS works always -->
<accelerator key="F10" signal="clicked" />
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
</object> <!-- ./GtkHeaderBar -->
</child>
</template>
<object class="GtkPopoverMenu" id="main_menu">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton">
<property name="text" translatable="yes">_About</property>
<signal name="clicked" handler="mgt_window_show_about" swapped="1" />
<!-- THIS works only when menu is open -->
<accelerator key="F9" signal="clicked" />
</object>
</child>
</object>
</child>
</object>
</interface>