Fix editor shortcuts not working

This commit is contained in:
Serhii Snitsaruk 2024-01-14 21:48:15 +01:00
parent 73c6bfe2c7
commit 61790085cc
4 changed files with 22 additions and 8 deletions

View File

@ -321,7 +321,7 @@ void LimboAIEditor::_extract_subtree(const String &p_path) {
} }
void LimboAIEditor::_process_shortcut_input(const Ref<InputEvent> &p_event) { void LimboAIEditor::_process_shortcut_input(const Ref<InputEvent> &p_event) {
if (!p_event->is_pressed()) { if (!p_event->is_pressed() || p_event->is_echo()) {
return; return;
} }
@ -1116,7 +1116,7 @@ LimboAIEditor::LimboAIEditor() {
LW_SHORTCUT("limbo_ai/load_behavior_tree", TTR("Load Behavior Tree"), (Key)(LW_KEY_MASK(CMD_OR_CTRL) | LW_KEY_MASK(ALT) | LW_KEY(L))); LW_SHORTCUT("limbo_ai/load_behavior_tree", TTR("Load Behavior Tree"), (Key)(LW_KEY_MASK(CMD_OR_CTRL) | LW_KEY_MASK(ALT) | LW_KEY(L)));
LW_SHORTCUT("limbo_ai/open_debugger", TTR("Open Debugger"), (Key)(LW_KEY_MASK(CMD_OR_CTRL) | LW_KEY_MASK(ALT) | LW_KEY(D))); LW_SHORTCUT("limbo_ai/open_debugger", TTR("Open Debugger"), (Key)(LW_KEY_MASK(CMD_OR_CTRL) | LW_KEY_MASK(ALT) | LW_KEY(D)));
set_process_shortcut_input(true); set_process_input(true);
save_dialog = memnew(FileDialog); save_dialog = memnew(FileDialog);
save_dialog->set_file_mode(FileDialog::FILE_MODE_SAVE_FILE); save_dialog->set_file_mode(FileDialog::FILE_MODE_SAVE_FILE);

View File

@ -209,7 +209,7 @@ public:
void apply_changes(); void apply_changes();
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
virtual void _shortcut_input(const Ref<InputEvent> &p_event) override { _process_shortcut_input(p_event); } virtual void _input(const Ref<InputEvent> &p_event) override { _process_shortcut_input(p_event); }
#endif #endif
LimboAIEditor(); LimboAIEditor();

View File

@ -24,6 +24,7 @@ android.release.arm64 = "res://addons/limboai/bin/liblimboai.android.template_re
[icons] [icons]
BehaviorTree = "res://addons/limboai/icons/BehaviorTree.svg"
BTAction = "res://addons/limboai/icons/BTAction.svg" BTAction = "res://addons/limboai/icons/BTAction.svg"
BTAlwaysFail = "res://addons/limboai/icons/BTAlwaysFail.svg" BTAlwaysFail = "res://addons/limboai/icons/BTAlwaysFail.svg"
BTAlwaysSucceed = "res://addons/limboai/icons/BTAlwaysSucceed.svg" BTAlwaysSucceed = "res://addons/limboai/icons/BTAlwaysSucceed.svg"
@ -67,13 +68,12 @@ BTSubtree = "res://addons/limboai/icons/BTSubtree.svg"
BTTimeLimit = "res://addons/limboai/icons/BTTimeLimit.svg" BTTimeLimit = "res://addons/limboai/icons/BTTimeLimit.svg"
BTWait = "res://addons/limboai/icons/BTWait.svg" BTWait = "res://addons/limboai/icons/BTWait.svg"
BTWaitTicks = "res://addons/limboai/icons/BTWaitTicks.svg" BTWaitTicks = "res://addons/limboai/icons/BTWaitTicks.svg"
BehaviorTree = "res://addons/limboai/icons/BehaviorTree.svg"
LimboAI = "res://addons/limboai/icons/LimboAI.svg" LimboAI = "res://addons/limboai/icons/LimboAI.svg"
LimboDeselectAll = "res://addons/limboai/icons/LimboDeselectAll.svg" LimboDeselectAll = "res://addons/limboai/icons/LimboDeselectAll.svg"
LimboExtraBlackboard = "res://addons/limboai/icons/LimboExtraBlackboard.svg" LimboExtraBlackboard = "res://addons/limboai/icons/LimboExtraBlackboard.svg"
LimboExtraClock = "res://addons/limboai/icons/LimboExtraClock.svg" LimboExtraClock = "res://addons/limboai/icons/LimboExtraClock.svg"
LimboExtraVariable = "res://addons/limboai/icons/LimboExtraVariable.svg"
LimboExtractSubtree = "res://addons/limboai/icons/LimboExtractSubtree.svg" LimboExtractSubtree = "res://addons/limboai/icons/LimboExtractSubtree.svg"
LimboExtraVariable = "res://addons/limboai/icons/LimboExtraVariable.svg"
LimboHSM = "res://addons/limboai/icons/LimboHSM.svg" LimboHSM = "res://addons/limboai/icons/LimboHSM.svg"
LimboPercent = "res://addons/limboai/icons/LimboPercent.svg" LimboPercent = "res://addons/limboai/icons/LimboPercent.svg"
LimboSelectAll = "res://addons/limboai/icons/LimboSelectAll.svg" LimboSelectAll = "res://addons/limboai/icons/LimboSelectAll.svg"

View File

@ -295,13 +295,27 @@ Ref<Shortcut> LimboUtility::add_shortcut(const String &p_path, const String &p_n
sc->set_name(p_name); sc->set_name(p_name);
Array events; Array events;
Key keycode = p_keycode;
Ref<InputEventKey> ev = memnew(InputEventKey); Ref<InputEventKey> ev = memnew(InputEventKey);
ev->set_keycode(p_keycode); if (((int)LW_KEY_MASK(CMD_OR_CTRL) & (int)keycode) == (int)LW_KEY_MASK(CMD_OR_CTRL)) {
keycode = (Key)((int)keycode & (~((int)LW_KEY_MASK(CMD_OR_CTRL))));
ev->set_ctrl_pressed(true);
}
if (((int)LW_KEY_MASK(ALT) & (int)keycode) == (int)LW_KEY_MASK(ALT)) {
keycode = (Key)((int)keycode & (~((int)LW_KEY_MASK(ALT))));
ev->set_alt_pressed(true);
}
if (((int)LW_KEY_MASK(SHIFT) & (int)keycode) == (int)LW_KEY_MASK(SHIFT)) {
keycode = (Key)((int)keycode & (~((int)LW_KEY_MASK(SHIFT))));
ev->set_shift_pressed(true);
}
ev->set_keycode(keycode);
ev->set_pressed(true);
events.append(ev); events.append(ev);
sc->set_events(events); sc->set_events(events);
shortcuts[p_path] = sc; shortcuts[p_path] = sc;
return sc; return sc;
} }