Fix T93446: search box active result does not reset when typing
Whenever the user edits the query in a search box, the active (highlighted) result resets to the first. Previously, it would remain at the last highlighted result, jumping around as the results update. This is better than the previous behavior. If a user highlights a choice either on purpose or by accidental mouse movement and continues to type, it is likely that they are not looking for the currently highlighted choice, so setting it to the top search result is more useful. Differential Revision: https://developer.blender.org/D15211
This commit is contained in:
parent
33bad77043
commit
257b4d138c
@ -451,15 +451,16 @@ void ui_searchbox_update(bContext *C, ARegion *region, uiBut *but, const bool re
|
||||
/* reset vars */
|
||||
data->items.totitem = 0;
|
||||
data->items.more = 0;
|
||||
if (reset == false) {
|
||||
if (!reset) {
|
||||
data->items.offset_i = data->items.offset;
|
||||
}
|
||||
else {
|
||||
data->items.offset_i = data->items.offset = 0;
|
||||
data->active = -1;
|
||||
|
||||
/* handle active */
|
||||
if (search_but->items_update_fn && search_but->item_active) {
|
||||
/* On init, find and center active item. */
|
||||
const bool is_first_search = !search_but->but.changed;
|
||||
if (is_first_search && search_but->items_update_fn && search_but->item_active) {
|
||||
data->items.active = search_but->item_active;
|
||||
ui_searchbox_update_fn(C, search_but, but->editstr, &data->items);
|
||||
data->items.active = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user