Accept Ctrl-J when LimboAI editor is visible and fix shortcuts not working sometimes

This commit is contained in:
Serhii Snitsaruk 2024-05-29 11:58:59 +02:00
parent 88e468c526
commit 2b299c0007
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
1 changed files with 39 additions and 33 deletions

View File

@ -352,12 +352,19 @@ void LimboAIEditor::_process_shortcut_input(const Ref<InputEvent> &p_event) {
get_viewport()->set_input_as_handled(); get_viewport()->set_input_as_handled();
} }
// * Local shortcuts. // * When editor is on screen.
if (!(has_focus() || get_viewport()->gui_get_focus_owner() == nullptr || is_ancestor_of(get_viewport()->gui_get_focus_owner()))) { if (is_visible_in_tree()) {
if (LW_IS_SHORTCUT("limbo_ai/jump_to_owner", p_event)) {
_tab_menu_option_selected(TAB_JUMP_TO_OWNER);
get_viewport()->set_input_as_handled();
return; return;
} }
}
// * When editor is focused.
if (has_focus() || (get_viewport()->gui_get_focus_owner() && is_ancestor_of(get_viewport()->gui_get_focus_owner()))) {
if (LW_IS_SHORTCUT("limbo_ai/rename_task", p_event)) { if (LW_IS_SHORTCUT("limbo_ai/rename_task", p_event)) {
_action_selected(ACTION_RENAME); _action_selected(ACTION_RENAME);
} else if (LW_IS_SHORTCUT("limbo_ai/cut_task", p_event)) { } else if (LW_IS_SHORTCUT("limbo_ai/cut_task", p_event)) {
@ -382,13 +389,12 @@ void LimboAIEditor::_process_shortcut_input(const Ref<InputEvent> &p_event) {
_on_save_pressed(); _on_save_pressed();
} else if (LW_IS_SHORTCUT("limbo_ai/load_behavior_tree", p_event)) { } else if (LW_IS_SHORTCUT("limbo_ai/load_behavior_tree", p_event)) {
_popup_file_dialog(load_dialog); _popup_file_dialog(load_dialog);
} else if (LW_IS_SHORTCUT("limbo_ai/jump_to_owner", p_event)) {
_tab_menu_option_selected(TAB_JUMP_TO_OWNER);
} else { } else {
return; return;
} }
get_viewport()->set_input_as_handled(); get_viewport()->set_input_as_handled();
}
} }
void LimboAIEditor::_on_tree_rmb(const Vector2 &p_menu_pos) { void LimboAIEditor::_on_tree_rmb(const Vector2 &p_menu_pos) {