Simplify script list click logic
This commit is contained in:
parent
889c522a19
commit
2855b591fb
|
@ -3059,26 +3059,15 @@ void ScriptEditor::shortcut_input(const Ref<InputEvent> &p_event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) {
|
void ScriptEditor::_script_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index) {
|
||||||
Ref<InputEventMouseButton> mb = ev;
|
if (p_mouse_button_index == MouseButton::MIDDLE) {
|
||||||
if (mb.is_valid() && mb->is_pressed()) {
|
script_list->select(p_item);
|
||||||
switch (mb->get_button_index()) {
|
_script_selected(p_item);
|
||||||
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);
|
_menu_option(FILE_CLOSE);
|
||||||
}
|
}
|
||||||
} break;
|
|
||||||
|
|
||||||
case MouseButton::RIGHT: {
|
if (p_mouse_button_index == MouseButton::RIGHT) {
|
||||||
_make_script_list_context_menu();
|
_make_script_list_context_menu();
|
||||||
} break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3688,7 +3677,7 @@ ScriptEditor::ScriptEditor() {
|
||||||
script_list->set_v_size_flags(SIZE_EXPAND_FILL);
|
script_list->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
script_split->set_split_offset(70 * EDSCALE);
|
script_split->set_split_offset(70 * EDSCALE);
|
||||||
_sort_list_on_update = true;
|
_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_allow_rmb_select(true);
|
||||||
script_list->set_drag_forwarding(this);
|
script_list->set_drag_forwarding(this);
|
||||||
|
|
||||||
|
|
|
@ -427,7 +427,7 @@ class ScriptEditor : public PanelContainer {
|
||||||
virtual void input(const Ref<InputEvent> &p_event) override;
|
virtual void input(const Ref<InputEvent> &p_event) override;
|
||||||
virtual void shortcut_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 _make_script_list_context_menu();
|
||||||
|
|
||||||
void _help_search(String p_text);
|
void _help_search(String p_text);
|
||||||
|
|
Loading…
Reference in New Issue