Page MenuHome

Selection menu for properties does not preselect current item.
Open, Confirmed, LowPublic


System Information
Operating system:
Graphics card:

Blender Version
2.80, a3261aad130e, 2019-01-04
2.79, f4dc9f9d68b, 2018-03-22 (is slightly less broken than 2.80)

Short description of error
No item or the wrong item is selected when the selection menu of a property is opened.

Exact steps for others to reproduce the error
Open default startup .blend.
Add "Copy Location" constraint to "Cube". (Bug is not limited to constraints.)
Set Target to "Light"
Open selection menu again for Target. "Camera" will be highlighted instead of "Light".

Possible fix
The attached diff passes the data behind PointerRNA *ptr as active item. This ends up in overwriting the current value of but->func_arg2. I can't tell whether this will cause problems somewhere else.



Event Timeline

Jacques Lucke (JacquesLucke) triaged this task as Confirmed, Medium priority.Jan 24 2019, 3:25 PM

Can confirm.

Best would be if you submit you proposed fix as patch so that devs that know more about the side effects can do a code review.

Campbell Barton (campbellbarton) lowered the priority of this task from Confirmed, Medium to Confirmed, Low.Mon, Apr 29, 6:47 AM

Setting low priority since this isn't new in 2.8x.

I think the easiest way to fix this, is to use the property value as active item in ui_searchbox_update.

I previously thought that but->func_arg2 was NULL whenever the active item was not displayed correctly. But apparently it is set to block->func_arg2. And the same happens with but->func. This means there is not really a way to update func_arg2 without messing up the expected arguments for func.

This works fine with PROP_POINTER, and as before for everything else:

diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index 251bc86a3f5..a647693b75f 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -325,9 +325,20 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset)
     data->items.offset_i = data->items.offset = 0;
     data->active = -1;

-    /* handle active */
-    if (but->search_func && but->func_arg2) {
+    if (but-> && but->rnaprop && RNA_property_type(but->rnaprop) == PROP_POINTER) {
+      /* Buttons that prepare the search box through ui_but_add_search get in ui_def_but their
+       * func_arg2 set to the same value as its block. Therefore if we have a property, using the
+       * property value as the active item makes more sense here.
+       */
+      PointerRNA ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
+      data-> =;
+    }
+    else {
       data-> = but->func_arg2;
+    }
+    /* handle active */
+    if (but->search_func && data-> {
       but->search_func(C, but->search_arg, but->editstr, &data->items);
       data-> = NULL;