0
$\begingroup$

I am trying to use template_list with custom items but I cannot make them change values on double click. I want to change 'name' property the same way I can rename items in other lists (with double click).

Part of the code:

class ListItem(bpy.types.PropertyGroup):
    """ Group of properties representing an item in the list """  
    name = StringProperty(
            name="Profile Name",
            default="Untitled")

    empty_name = StringProperty(
            name="Name of Empty holding profile",
            description="",
            default="")

class BLS_UL_List(bpy.types.UIList):
    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
        custom_icon = 'OUTLINER_OB_LAMP' if index == context.scene.BLStudio.list_index else 'LAMP'

        # Make sure your code supports all 3 layout types
        if self.layout_type in {'DEFAULT', 'COMPACT'}:
            layout.label(item.name, icon = custom_icon)

        elif self.layout_type in {'GRID'}:
            layout.alignment = 'CENTER'
            layout.label("", icon = custom_icon)

class BLS_ProfileList(bpy.types.Panel):
    bl_idname = "bls_profile_list"
    bl_label = "Profiles"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_category = "Light Studio"

    def draw(self, context):
        layout = self.layout
        scene = context.scene

        props = scene.BLStudio

        row = layout.row()
        col = row.column()
        col.template_list("BLS_UL_List", "Profile_List", props, "profile_list", props, "list_index", rows=4)

EDIT: Problem solved thanks to poor's comment. The solution is to change

layout.label(item.name, icon = custom_icon)

to

layout.prop(item, 'name', text='', icon = custom_icon, emboss=False, translate=False)
$\endgroup$
2

0

Browse other questions tagged .