summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2022-07-28 13:38:13 +0200
committerkobewi <kobewi4e@gmail.com>2022-08-30 13:38:03 +0200
commit2855b591fb33f59838f74ca4cc6eb6f662a56fa3 (patch)
treea2c4d04feb34b7dfa04fcdd9100126b1bbf437d7 /editor/plugins
parent889c522a1954a11df93e3db59f61e41967c099d7 (diff)
Simplify script list click logic
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/script_editor_plugin.cpp29
-rw-r--r--editor/plugins/script_editor_plugin.h2
2 files changed, 10 insertions, 21 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index aa1d630372..114b041892 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 d1898efb69..822a23e59f 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -427,7 +427,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);