Label's mnemonic-keyval isn't always the actual accelerator key when using double underscore escaping
Steps to reproduce
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkBox" id="foo">
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="visible">true</property>
<child>
<object class="GtkButton" id="find_button">
<property name="label" translatable="yes">_Find in src/npm__plugin.py (F is underlined and the npm underscore is a double one)</property>
<property name="use-underline">True</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkButton" id="replace_button">
<property name="label" translatable="yes">Find in src/npm__plugin.py _mnemonic (npm's underscore is doubled and the m of mnemonic is underlined too)</property>
<property name="use-underline">True</property>
<property name="visible">true</property>
</object>
</child>
</object>
</interface>
- Download the above file in bar.ui
- Run
gtk4-builder-tool preview --id=foo bar.ui
- Press
Alt+_
thenAlt+m
Behavior
The _
underscore mnemonic can't be activated, and the m
one of the second button can. So the double underscore seems to be correctly handled as an escaped underscore that shouldn't be activatable nor underlined (though obviously for the later I've no idea if it actually underlined it since they likely overlap). This is expected.
But checking in the GTK inspector of the second label, the value of the mnemonic-keyval property is the one corresponding to the underscore, not to the m
. This can be seen by removing the double underscore: the value of mnemonic-keyval will change where it shouldn't have if it was m
from the beginning.
So while this mnemonic-keyval inconstancy doesn't break the mnemonic when there's a double underscore, it's still inconsistent with the mnemonic key can actually be used.
Version information
GTK4 from gnome-nightly sdk.