Attempt to fix keybindings not working from plugins.
This commit is contained in:
parent
815d39fc3f
commit
c712bea421
@ -72,8 +72,22 @@ class APIHelper:
|
|||||||
# Handle Cthulhu modifier specially
|
# Handle Cthulhu modifier specially
|
||||||
if "cthulhu+" in key.lower():
|
if "cthulhu+" in key.lower():
|
||||||
from . import keybindings
|
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
|
# Create a keybinding handler
|
||||||
class GestureHandler:
|
class GestureHandler:
|
||||||
def __init__(self, function, description):
|
def __init__(self, function, description):
|
||||||
@ -90,9 +104,9 @@ class APIHelper:
|
|||||||
if cthulhu_state.activeScript:
|
if cthulhu_state.activeScript:
|
||||||
bindings = cthulhu_state.activeScript.getKeyBindings()
|
bindings = cthulhu_state.activeScript.getKeyBindings()
|
||||||
binding = keybindings.KeyBinding(
|
binding = keybindings.KeyBinding(
|
||||||
key,
|
final_key,
|
||||||
keybindings.defaultModifierMask,
|
keybindings.defaultModifierMask,
|
||||||
keybindings.CTHULHU_MODIFIER_MASK,
|
modifiers,
|
||||||
handler)
|
handler)
|
||||||
bindings.add(binding)
|
bindings.add(binding)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user