Hey all, I have a dynamic property group here that gets built. Works just fine however i want to identify which item has been clicked when update function is called.
# update function
def update(instance, context):
print('how do i know which enum property was selected?..')
# registering elsewhere in code...
for key, item_values in data.items():
items = []
for each in item_values:
items.append((each, each, ''))
annotations[key] = bpy.props.EnumProperty(
name=key,
items=items,
update=update
)
MyProps= type(
# Class name
"MyProps",
# Base class
(bpy.types.PropertyGroup,),
{"__annotations__": annotations},
)
bpy.utils.register_class(MyProps)
bpy.types.Scene.my_props= bpy.props.PointerProperty(type=MyProps)`
I thought turning my update property into a lambda might work
name=key,
items=items,
update=lambda inst, ctx: update(inst, ctx, key)
But unfortunately the last key in the loop is the one passed. I’ve currently got a hacky workaround which is i run through every key in the PropertyGroup and update accordingly everytime update def is called.