Improve key detection in registerGestureByString

This commit is contained in:
Storm Dragon 2025-04-19 15:39:43 -04:00
parent 8b1f501fe7
commit 39dca0574a

View File

@ -60,19 +60,16 @@ class APIHelper:
from . import keybindings from . import keybindings
key_parts = key.lower().split("+") key_parts = key.lower().split("+")
# Determine appropriate modifier mask # Start with the base Cthulhu modifier
modifiers = keybindings.CTHULHU_MODIFIER_MASK modifiers = keybindings.CTHULHU_MODIFIER_MASK
# Extract the final key (without modifiers) # Extract the final key (without modifiers)
final_key = key_parts[-1] final_key = key_parts[-1]
# Check for additional modifiers # Check for additional modifiers and combine them properly
if "shift" in key_parts: if "shift" in key_parts:
# Use the pre-defined combined mask rather than trying to OR them
modifiers = keybindings.CTHULHU_SHIFT_MODIFIER_MASK modifiers = keybindings.CTHULHU_SHIFT_MODIFIER_MASK
elif "ctrl" in key_parts or "control" in key_parts:
modifiers = keybindings.CTHULHU_CTRL_MODIFIER_MASK
elif "alt" in key_parts:
modifiers = keybindings.CTHULHU_ALT_MODIFIER_MASK
# Create a keybinding handler # Create a keybinding handler
class GestureHandler: class GestureHandler:
@ -104,8 +101,8 @@ class APIHelper:
bindings.add(binding) bindings.add(binding)
# Store binding for later reference # Store binding for later reference
if contextName not in self._gestureBindings: if contextName not in self._gestureBindings:
self._gestureBindings[contextName] = [] self._gestureBindings[contextName] = []
self._gestureBindings[contextName].append(binding) self._gestureBindings[contextName].append(binding)
# Register key grab at the system level # Register key grab at the system level