Compare commits

..

2 Commits

Author SHA1 Message Date
monxa 8ac2219d32
Merge 20be87904a into 60a767032e 2024-09-29 19:47:54 +00:00
Alexander Montag 20be87904a
Focus tree when search panel is closed 2024-09-29 21:47:38 +02:00
2 changed files with 9 additions and 0 deletions

View File

@ -383,6 +383,12 @@ void TreeSearch::_select_next_match() {
_select_first_match();
}
void TreeSearch::_on_search_panel_visibility_changed() {
if (tree_reference && !search_panel->is_visible()) {
tree_reference->grab_focus();
}
}
template <typename T>
inline bool TreeSearch::_vector_has_bsearch(Vector<T *> &p_vec, T *element) const {
int idx = p_vec.bsearch(element, true);
@ -439,6 +445,7 @@ void TreeSearch::update_search(Tree *p_tree) {
TreeSearch::TreeSearch(TreeSearchPanel *p_search_panel) {
search_panel = p_search_panel;
search_panel->connect("text_submitted", callable_mp(this, &TreeSearch::_select_next_match));
search_panel->connect("visibility_changed", callable_mp(this, &TreeSearch::_on_search_panel_visibility_changed));
}
/* !TreeSearch */

View File

@ -90,6 +90,8 @@ private:
void _select_first_match();
void _select_next_match();
void _on_search_panel_visibility_changed();
// TODO: make p_vec ref `const` once Vector::bsearch is const. See: https://github.com/godotengine/godot/pull/90341
template <typename T>
bool _vector_has_bsearch(Vector<T *> &p_vec, T *element) const;