From c712bea421206f77e227901a6b05e65bae216eb6 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Fri, 4 Apr 2025 16:03:35 -0400 Subject: [PATCH] Attempt to fix keybindings not working from plugins. --- src/cthulhu/cthulhu.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/cthulhu/cthulhu.py b/src/cthulhu/cthulhu.py index fcf628b..ed26293 100644 --- a/src/cthulhu/cthulhu.py +++ b/src/cthulhu/cthulhu.py @@ -72,8 +72,22 @@ class APIHelper: # Handle Cthulhu modifier specially if "cthulhu+" in key.lower(): from . import keybindings - key = key.lower().replace("cthulhu+", "") + key_parts = key.lower().split("+") + # Determine appropriate modifier mask + modifiers = keybindings.CTHULHU_MODIFIER_MASK + + # Extract the final key (without modifiers) + final_key = key_parts[-1] + + # Check for additional modifiers + if "shift" in key_parts: + 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 class GestureHandler: def __init__(self, function, description): @@ -90,9 +104,9 @@ class APIHelper: if cthulhu_state.activeScript: bindings = cthulhu_state.activeScript.getKeyBindings() binding = keybindings.KeyBinding( - key, + final_key, keybindings.defaultModifierMask, - keybindings.CTHULHU_MODIFIER_MASK, + modifiers, handler) bindings.add(binding)