Skip to content

Commit

Permalink
Fix editor shortcuts not working
Browse files Browse the repository at this point in the history
  • Loading branch information
limbonaut committed Jan 14, 2024
1 parent 73c6bfe commit 6179008
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions editor/limbo_ai_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void LimboAIEditor::_extract_subtree(const String &p_path) {
}

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;
}

Expand Down Expand Up @@ -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/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->set_file_mode(FileDialog::FILE_MODE_SAVE_FILE);
Expand Down
2 changes: 1 addition & 1 deletion editor/limbo_ai_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class LimboAIEditor : public Control {
void apply_changes();

#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

LimboAIEditor();
Expand Down
4 changes: 2 additions & 2 deletions gdextension/limboai.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ android.release.arm64 = "res://addons/limboai/bin/liblimboai.android.template_re

[icons]

BehaviorTree = "res://addons/limboai/icons/BehaviorTree.svg"
BTAction = "res://addons/limboai/icons/BTAction.svg"
BTAlwaysFail = "res://addons/limboai/icons/BTAlwaysFail.svg"
BTAlwaysSucceed = "res://addons/limboai/icons/BTAlwaysSucceed.svg"
Expand Down Expand Up @@ -67,13 +68,12 @@ BTSubtree = "res://addons/limboai/icons/BTSubtree.svg"
BTTimeLimit = "res://addons/limboai/icons/BTTimeLimit.svg"
BTWait = "res://addons/limboai/icons/BTWait.svg"
BTWaitTicks = "res://addons/limboai/icons/BTWaitTicks.svg"
BehaviorTree = "res://addons/limboai/icons/BehaviorTree.svg"
LimboAI = "res://addons/limboai/icons/LimboAI.svg"
LimboDeselectAll = "res://addons/limboai/icons/LimboDeselectAll.svg"
LimboExtraBlackboard = "res://addons/limboai/icons/LimboExtraBlackboard.svg"
LimboExtraClock = "res://addons/limboai/icons/LimboExtraClock.svg"
LimboExtraVariable = "res://addons/limboai/icons/LimboExtraVariable.svg"
LimboExtractSubtree = "res://addons/limboai/icons/LimboExtractSubtree.svg"
LimboExtraVariable = "res://addons/limboai/icons/LimboExtraVariable.svg"
LimboHSM = "res://addons/limboai/icons/LimboHSM.svg"
LimboPercent = "res://addons/limboai/icons/LimboPercent.svg"
LimboSelectAll = "res://addons/limboai/icons/LimboSelectAll.svg"
Expand Down
20 changes: 17 additions & 3 deletions util/limbo_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,27 @@ Ref<Shortcut> LimboUtility::add_shortcut(const String &p_path, const String &p_n
sc->set_name(p_name);

Array events;

Key keycode = p_keycode;
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);
sc->set_events(events);

shortcuts[p_path] = sc;

return sc;
}

Expand Down

0 comments on commit 6179008

Please sign in to comment.