Page MenuHome

UI: Expose an "is first search" boolean to search button callbacks
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Feb 25 2021, 12:49 AM.

Details

Summary

Currently when you open an RNA collection search button, like a
vertex group selector, the search filter isn't applied until you
start typing, in order to list every option at the start. Otherwise
they wouldn't be visible, since the search filter would run.

Currently this same check happens in one place, but it checks the
changed value of uiBut. This is fine in the interface directory,
but anywhere else it doesn't work. And I think exposing uiBut.changed
is not a good idea, since it's too general and is only used for this
specific situation anyway.

So, the solution is adding an is_first argument to the search
callbacks, which is nice for a few reasons:

  • They work at a higher level of abstraction, meaning they don't have to worry about how exactly to tell if this is the first search.
  • It makes it easier to do special behavior when the search menu is first opened.
  • Then, obviously, it makes that state accessible without including interface_intern.h.

Ref T85658

Diff Detail

Repository
rB Blender

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Feb 25 2021, 12:49 AM
Hans Goudey (HooglyBoogly) created this revision.

Generally fine, some considerations.

  • uiButSearchUpdateFn docstring should note that is_first is typically used to skip filtering.
  • Is is_first guaranteed to run once true, then false - in all cases? If not, it could be renamed to skip_filter for example.

    Or, note that this depends on button-changed state and isn't suitable for one-off initialization - as it's name implies.

Accepting, without an extra review iteration.

This revision is now accepted and ready to land.Feb 26 2021, 7:23 AM