diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-02-09 12:53:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-09 12:53:37 +0100 |
commit | e420b85ba50ef2afd1d98dec28843f17d3dec3ef (patch) | |
tree | 91bc6214b148e689ce540d8380b5a15f125aafdd | |
parent | 7f95e027b45842c62dac3bc415de22b97c1abcc3 (diff) | |
parent | 421ea09195d7d8dcd904eed764d62e956233e7cd (diff) |
Merge pull request #35840 from timothyqiu/groups-match
Fixes add group in Group Editor dialog
-rw-r--r-- | editor/groups_editor.cpp | 2 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 11 | ||||
-rw-r--r-- | scene/gui/tree.h | 3 |
3 files changed, 15 insertions, 1 deletions
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 83259afb35..c76ff9d679 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -197,7 +197,7 @@ void GroupDialog::_add_group(String p_name) { } String name = p_name.strip_edges(); - if (name == "" || groups->search_item_text(name)) { + if (name.empty() || groups->get_item_with_text(name)) { return; } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 6e38a0aa1f..790e1d5f4f 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3630,6 +3630,17 @@ TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_select return _search_item_text(from->get_next_visible(true), p_find, r_col, p_selectable); } +TreeItem *Tree::get_item_with_text(const String &p_find) const { + for (TreeItem *current = root; current; current = current->get_next_visible()) { + for (int i = 0; i < columns.size(); i++) { + if (current->get_text(i) == p_find) { + return current; + } + } + } + return NULL; +} + void Tree::_do_incr_search(const String &p_add) { uint64_t time = OS::get_singleton()->get_ticks_usec() / 1000; // convert to msec diff --git a/scene/gui/tree.h b/scene/gui/tree.h index d87de6e773..f3c88eb5ac 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -577,7 +577,10 @@ public: Rect2 get_item_rect(TreeItem *p_item, int p_column = -1) const; bool edit_selected(); + // First item that starts with the text, from the current focused item down and wraps around. TreeItem *search_item_text(const String &p_find, int *r_col = NULL, bool p_selectable = false); + // First item that matches the whole text, from the first item down. + TreeItem *get_item_with_text(const String &p_find) const; Point2 get_scroll() const; void scroll_to_item(TreeItem *p_item); |