Scroll to selected item when filtering VisualScript nodes

This commit is contained in:
Haoyu Qiu 2022-04-09 10:14:09 +08:00
parent 33500a1529
commit 7c80d03669

View file

@ -92,10 +92,6 @@ void VisualScriptPropertySelector::_update_search() {
base = ClassDB::get_parent_class_nocheck(base); base = ClassDB::get_parent_class_nocheck(base);
} }
for (List<StringName>::Element *E = base_list.front(); E; E = E->next()) {
List<MethodInfo> methods;
List<PropertyInfo> props;
TreeItem *category = nullptr;
Ref<Texture> type_icons[Variant::VARIANT_MAX] = { Ref<Texture> type_icons[Variant::VARIANT_MAX] = {
Control::get_icon("Variant", "EditorIcons"), Control::get_icon("Variant", "EditorIcons"),
Control::get_icon("bool", "EditorIcons"), Control::get_icon("bool", "EditorIcons"),
@ -125,6 +121,11 @@ void VisualScriptPropertySelector::_update_search() {
Control::get_icon("PoolVector3Array", "EditorIcons"), Control::get_icon("PoolVector3Array", "EditorIcons"),
Control::get_icon("PoolColorArray", "EditorIcons") Control::get_icon("PoolColorArray", "EditorIcons")
}; };
for (List<StringName>::Element *E = base_list.front(); E; E = E->next()) {
List<MethodInfo> methods;
List<PropertyInfo> props;
TreeItem *category = nullptr;
{ {
String b = String(E->get()); String b = String(E->get());
category = search_options->create_item(root); category = search_options->create_item(root);
@ -304,6 +305,7 @@ void VisualScriptPropertySelector::_update_search() {
TreeItem *selected_item = search_options->search_item_text(search_box->get_text()); TreeItem *selected_item = search_options->search_item_text(search_box->get_text());
if (!found && selected_item != nullptr) { if (!found && selected_item != nullptr) {
selected_item->select(0); selected_item->select(0);
search_options->scroll_to_item(selected_item);
found = true; found = true;
} }