6
$\begingroup$

Dropdown list does not refresh when search operator changes its property.

Here is simple example script, use search operator and see how dropdown list updated only on mouseover.

dropdown list refresh issue demo

$\endgroup$
0

2 Answers 2

9
$\begingroup$

Ideally this would work without any explicit update or redraw calls, however - this issue can be resolved by tagging the area for redraw.

After the assignment call context.area.tag_redraw().


Note that normally it's best to use context.region.tag_redraw() (which would redraw only the panel), however it's not working in this case because this region isn't active when the pop-up executes.

You could store the region before executing the operator, but this is probably more hassle than it's worth.

$\endgroup$
0
2
$\begingroup$

Neither storing the region to redraw or using context.area is enough in general case, it is necessary to iterate through all open windows and areas, otherwise tag_redraw() will not work as expected (may cause a redraw in one window but nothing happens if what needs to be updated is in the other window, or update only in one window but not in the other).

This is the solution that worked for me. Just call the function with the space type and the region type which need to be updated.

def tag_redraw(context, space_type="PROPERTIES", region_type="WINDOW"):
    for window in context.window_manager.windows:
        for area in window.screen.areas:
            if area.spaces[0].type == space_type:
                for region in area.regions:
                    if region.type == region_type:
                        region.tag_redraw()

I find it surprising that there is no standard function in the API for this.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .