Merge pull request #70290 from aaronfranke/tree-signal

Improve clarity of Tree's activated/double-clicked signals
This commit is contained in:
Yuri Sizov 2023-01-25 02:05:13 +03:00 committed by GitHub
commit a3a42159e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 11 deletions

View File

@ -401,7 +401,7 @@
</signal>
<signal name="item_activated">
<description>
Emitted when an item's label is double-clicked.
Emitted when an item is double-clicked, or selected with a [code]ui_accept[/code] input event (e.g. using [kbd]Enter[/kbd] or [kbd]Space[/kbd] on the keyboard).
</description>
</signal>
<signal name="item_collapsed">
@ -415,16 +415,16 @@
Emitted when a custom button is pressed (i.e. in a [constant TreeItem.CELL_MODE_CUSTOM] mode cell).
</description>
</signal>
<signal name="item_double_clicked">
<description>
Emitted when an item's icon is double-clicked.
</description>
</signal>
<signal name="item_edited">
<description>
Emitted when an item is edited.
</description>
</signal>
<signal name="item_icon_double_clicked">
<description>
Emitted when an item's icon is double-clicked. For a signal that emits when any part of the item is double-clicked, see [signal item_activated].
</description>
</signal>
<signal name="item_mouse_selected">
<param index="0" name="position" type="Vector2" />
<param index="1" name="mouse_button_index" type="int" />

View File

@ -1286,6 +1286,7 @@ static const char *gdscript_signals_renames[][2] = {
{ "about_to_show", "about_to_popup" }, // Popup
{ "button_release", "button_released" }, // XRController3D
{ "cancelled", "canceled" }, // AcceptDialog
{ "item_double_clicked", "item_icon_double_clicked" }, // Tree
{ "network_peer_connected", "peer_connected" }, // MultiplayerAPI
{ "network_peer_disconnected", "peer_disconnected" }, // MultiplayerAPI
{ "network_peer_packet", "peer_packet" }, // MultiplayerAPI

View File

@ -3613,7 +3613,7 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec
scene_tree->connect("script_dropped", callable_mp(this, &SceneTreeDock::_script_dropped));
scene_tree->connect("nodes_dragged", callable_mp(this, &SceneTreeDock::_nodes_drag_begin));
scene_tree->get_scene_tree()->connect("item_double_clicked", callable_mp(this, &SceneTreeDock::_focus_node));
scene_tree->get_scene_tree()->connect("item_icon_double_clicked", callable_mp(this, &SceneTreeDock::_focus_node));
editor_selection->connect("selection_changed", callable_mp(this, &SceneTreeDock::_selection_changed));

View File

@ -3554,7 +3554,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
icon_size_x = icon_region.size.width;
}
}
// Icon is treated as if it is outside of the rect so that double clicking on it will emit the item_double_clicked signal.
// Icon is treated as if it is outside of the rect so that double clicking on it will emit the item_icon_double_clicked signal.
if (rtl) {
mpos.x = get_size().width - (mpos.x + icon_size_x);
} else {
@ -3562,10 +3562,10 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
}
if (rect.has_point(mpos)) {
if (!edit_selected()) {
emit_signal(SNAME("item_double_clicked"));
emit_signal(SNAME("item_icon_double_clicked"));
}
} else {
emit_signal(SNAME("item_double_clicked"));
emit_signal(SNAME("item_icon_double_clicked"));
}
}
pressing_for_editor = false;
@ -5257,7 +5257,7 @@ void Tree::_bind_methods() {
ADD_SIGNAL(MethodInfo("item_edited"));
ADD_SIGNAL(MethodInfo("custom_item_clicked", PropertyInfo(Variant::INT, "mouse_button_index")));
ADD_SIGNAL(MethodInfo("item_custom_button_pressed"));
ADD_SIGNAL(MethodInfo("item_double_clicked"));
ADD_SIGNAL(MethodInfo("item_icon_double_clicked"));
ADD_SIGNAL(MethodInfo("item_collapsed", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem")));
ADD_SIGNAL(MethodInfo("check_propagated_to_item", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem"), PropertyInfo(Variant::INT, "column")));
ADD_SIGNAL(MethodInfo("button_clicked", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::INT, "mouse_button_index")));