Another try to get keybindings working.

This commit is contained in:
Storm Dragon 2025-06-05 13:40:44 -04:00
parent 2090767794
commit e2364a154a
3 changed files with 21 additions and 0 deletions

View File

@ -663,6 +663,9 @@ def loadUserSettings(script=None, inputEvent=None, skipReloadMessage=False):
_scriptManager.activate()
_eventManager.activate()
# Refresh keybindings to include plugin bindings (after script manager is active)
cthulhuApp.getPluginSystemManager().refresh_active_script_keybindings()
cthulhuApp.getSignalManager().emitSignal('load-setting-begin')
# cthulhuApp.getPluginSystemManager().register_plugin_keybindings_with_active_script()

View File

@ -156,6 +156,22 @@ class PluginSystemManager:
import traceback
logger.error(traceback.format_exc())
def refresh_active_script_keybindings(self):
"""Force active script to refresh its keybindings to include plugin bindings."""
from . import cthulhu_state
if cthulhu_state.activeScript:
active_script = cthulhu_state.activeScript
with open('/tmp/plugin_registration.log', 'a') as f:
f.write(f"=== refresh_active_script_keybindings() CALLED ===\n")
f.write(f"Active script: {active_script.name}\n")
# Force the script to recreate its keybindings to include plugin bindings
old_keybindings = active_script.keyBindings
active_script.keyBindings = active_script.getKeyBindings()
with open('/tmp/plugin_registration.log', 'a') as f:
f.write(f"Keybindings refreshed: old={len(old_keybindings.keyBindings) if old_keybindings else 0}, new={len(active_script.keyBindings.keyBindings)}\n")
def register_plugin_keybindings_with_active_script(self):
"""Register all plugin keybindings with the active script."""

View File

@ -363,6 +363,8 @@ class Script(script.Script):
return keyBindings
def getExtensionBindings(self):
with open('/tmp/extension_bindings_debug.log', 'a') as f:
f.write(f"=== getExtensionBindings() called ===\n")
keyBindings = keybindings.KeyBindings()
bindings = self.notificationPresenter.get_bindings()