4
$\begingroup$

Dropdown list does not redraw when search operator changes it’s EnumProperty.
Here is simple example script.
Use search operator and see how dropdown list updated only on mouseover.

enter image description here

Important notes:

  • Do not suggest to use redraw_timer—it’s not recommended by documentation
  • I do not specifically need this combination of UI elements, I just need to have dropdown list with keyword search, if there is another UI element or combination of elements that would better suit the purpose then I will gladly use them instead
  • Do not suggest template_list this is not what I’m looking for, as I said: simple dropdown list with keyword search
$\endgroup$
0
6
$\begingroup$

Ideally this would worth 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 its best to use context.region.tag_redraw() (which would redraw only the panel), however its 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 then its worth.

$\endgroup$
0
0
$\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$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.