I'm new to python and I encounter a problem with update callback function.
I have a UiList of items, and I'm looking for a way to display a popup window when user click on one of the items in the lists. Since it looks like i have to use CollectionProperty to use UiList, i have setup one and use an EnumProperty inside.
My problem is: I can't find a way to callback update from the CollectionProperty; and writing the update in the EnumProperty doesn't seem to do anything in this case.
class SCENE_OT_source_populate(Operator):
bl_idname = "scene.source_populate"
bl_label = "Populate source"
def execute(self,context):
context.scene.SMSL.collection.clear()
preset = context.scene.StrewPresetDrop.StrewPresetDropdown
AssetList = GetAssetList.Specie(self, context, preset)
for Asset in AssetList:
item = context.scene.SMSL.collection.add()
Path = Asset.split(",")
item.name = Path[1]
item.description = Asset
return {'FINISHED'}
class SMSAsset(PropertyGroup):
type = EnumProperty(
items=(
('A', "Option A", ""),
('B', "Option B", ""),
)
)
#val = IntProperty()
class SMSList(PropertyGroup):
collection : CollectionProperty(
name = "SMSA",
type = SMSAsset)
active_user_index : IntProperty()
class SMS_UL_List(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.prop(item, "name", text="", emboss=False)
#layout.prop(item, "val", text="")
#layout.prop(item, "type", text="")
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
def register():
bpy.util.register_class(SMS_UL_Lists)
bpy.util.register_class(SCENE_OT_source_populate)
bpy.types.Scene.SMSL = PointerProperty(type= SMSList)
I looked in the blender doc and CollectionProperty is the only one witouth a Update callback. Is there a way to work around this please?