Merge pull request #150 from dkmvs/dkmvs-fixing-keybindings-with-shift

Fix: Allow Key Bindings with Shift-Modified Keys
This commit is contained in:
Matt Rose 2020-06-30 14:50:58 -04:00 committed by GitHub
commit 1aaf935a4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -1550,6 +1550,21 @@ class PrefsEditor:
def on_cellrenderer_accel_edited(self, liststore, path, key, mods, _code): def on_cellrenderer_accel_edited(self, liststore, path, key, mods, _code):
"""Handle an edited keybinding""" """Handle an edited keybinding"""
if mods & Gdk.ModifierType.SHIFT_MASK:
key_with_shift = Gdk.Keymap.translate_keyboard_state(
self.keybindings.keymap,
hardware_keycode=_code,
state=Gdk.ModifierType.SHIFT_MASK,
group=0,
)
keyval_lower, keyval_upper = Gdk.keyval_convert_case(key)
# Remove the Shift modifier from `mods` if a new key binding doesn't
# contain a letter and its key value (`key`) can't be modified by a
# Shift key.
if key_with_shift.level != 0 and keyval_lower == keyval_upper:
mods = Gdk.ModifierType(mods & ~Gdk.ModifierType.SHIFT_MASK)
celliter = liststore.get_iter_from_string(path) celliter = liststore.get_iter_from_string(path)
liststore.set(celliter, 2, key, 3, mods) liststore.set(celliter, 2, key, 3, mods)