Focus tree when search panel is closed
This commit is contained in:
parent
e8de3adc50
commit
20be87904a
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue