Is there a way to trigger a single update event after selecting color via custom property?


I am trying to find a way to execute a function only once after a FloatVectorProperty with subtype="COLOR_GAMMA" is changed. I thought that I might be able to plug my function in for the update parameter, but that seems to be called any time the color is changed, meaning it gets called constantly as the user is moving around the color picker.

I need to execute the function only once after the user has finished selecting their color and the color picker popup has been closed.

Does anyone know how I might be able to do that?


Just use the “update” parameter in FloatVectorProperty… unless I’m not understanding what you’re asking for.

def my_update_func(self, context):
my_prop = bpy.props.FloatVectorProperty ( name="whatever", update=my_update_func )

Docs: FloatVectorProperty

Unfortunately, that is what I mentioned not working for my use case in my original post. The update function is called every time the color changes, which occurs constantly as the artist is using the color picker. The function that I need to trigger needs to iterate over a fairly large dictionary, and it is not practical to call it on every update (it causes the color picker gui to lag). What I want is for the user to be able to use the color picker popup to select a color, and then once the color has been selected and the popup closes, I am able to trigger my function to be called only once at the end.

To elaborate, I have a dictionary stored as a json string that has about 27,000 entries. The color property is used as one of several filters for this data set. Loading the dictionary from the string and then applying the filters as I iterate over all of the entries takes less than a second (probably less than a quarter of a second), but that is still not quite fast enough if update is being called constantly.

Ah I see, I missed your mention of update in the original post. Unfortunately I’m not aware of a way to achieve the result you’re looking for. Potentially through some hacky use of timers or depsgraph update handlers you could monitor the window manager for changes in the area that is relevant to your popup, but that’s a pretty deep rabbit hole. Hopefully someone else chimes in with a better idea!

Thank you for mentioning timers, I think I have an idea of how I might be able to get it to work using something like that (set a timer and a lock on update, then keep the timer going in intervals until the value doesn’t change).

Still feels like it would make sense to be able to just have an event to trigger a callback once the dialog closes though…

definitely, I’ve long been an advocate for an event driven python API

Why don’t do just something like this?

def update_prop(self, context):
    if not was_done:
        was_done = True