diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-21 15:38:41 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-21 15:38:41 +0200 |
commit | 53d2a9acddf4df5ba7819c154a8a52dc58ddcd1d (patch) | |
tree | 6d4a453903c84ad0b17a27ae2077397009ccedbb /editor/plugins | |
parent | a1d7404efcdd48b49966446d67da35ff9e63744d (diff) | |
parent | 2855b591fb33f59838f74ca4cc6eb6f662a56fa3 (diff) |
Merge pull request #63576 from KoBeWi/list_clicker
Simplify script list click logic
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 29 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.h | 2 |
2 files changed, 10 insertions, 21 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 0a111aeb49..8791da8245 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -3059,26 +3059,15 @@ void ScriptEditor::shortcut_input(const Ref<InputEvent> &p_event) { } } -void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) { - Ref<InputEventMouseButton> mb = ev; - if (mb.is_valid() && mb->is_pressed()) { - switch (mb->get_button_index()) { - case MouseButton::MIDDLE: { - // Right-click selects automatically; middle-click does not. - int idx = script_list->get_item_at_position(mb->get_position(), true); - if (idx >= 0) { - script_list->select(idx); - _script_selected(idx); - _menu_option(FILE_CLOSE); - } - } break; +void ScriptEditor::_script_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index) { + if (p_mouse_button_index == MouseButton::MIDDLE) { + script_list->select(p_item); + _script_selected(p_item); + _menu_option(FILE_CLOSE); + } - case MouseButton::RIGHT: { - _make_script_list_context_menu(); - } break; - default: - break; - } + if (p_mouse_button_index == MouseButton::RIGHT) { + _make_script_list_context_menu(); } } @@ -3688,7 +3677,7 @@ ScriptEditor::ScriptEditor() { script_list->set_v_size_flags(SIZE_EXPAND_FILL); script_split->set_split_offset(70 * EDSCALE); _sort_list_on_update = true; - script_list->connect("gui_input", callable_mp(this, &ScriptEditor::_script_list_gui_input), CONNECT_DEFERRED); + script_list->connect("item_clicked", callable_mp(this, &ScriptEditor::_script_list_clicked), CONNECT_DEFERRED); script_list->set_allow_rmb_select(true); script_list->set_drag_forwarding(this); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index a8e6cc6868..59191b8891 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -426,7 +426,7 @@ class ScriptEditor : public PanelContainer { virtual void input(const Ref<InputEvent> &p_event) override; virtual void shortcut_input(const Ref<InputEvent> &p_event) override; - void _script_list_gui_input(const Ref<InputEvent> &ev); + void _script_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index); void _make_script_list_context_menu(); void _help_search(String p_text); |