Attempt to fix keybindings not working from plugins.

This commit is contained in:
Storm Dragon 2025-04-04 16:03:35 -04:00
parent 815d39fc3f
commit c712bea421

View File

@ -72,7 +72,21 @@ 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:
@ -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)