Geometry Nodes: Allow clearing an attribute text field

Because pressing enter will choose the current search item from the menu,
and there was no search item with an empty string, it was impossible to
clear the text of an attribute text field. This commit adds a simple "X"
icon in the top row when you delete the string.
This commit is contained in:
Hans Goudey 2021-03-03 13:48:27 -06:00
parent f53221bff7
commit dd43a37016
1 changed files with 6 additions and 0 deletions

View File

@ -69,6 +69,12 @@ static void attribute_search_update_fn(
UI_search_item_add(items, str, (void *)str, ICON_ADD, 0, 0);
}
if (str[0] == '\0' && !is_first) {
/* Allow clearing the text field when the string is empty, but not on the first pass,
* or opening an attribute field for the first time would show this search item. */
UI_search_item_add(items, str, (void *)str, ICON_X, 0, 0);
}
/* Skip the filter when the menu is first opened, so all of the items are visible. */
if (is_first) {
for (const std::string &attribute_name : attribute_name_hints) {