From 4c52e737df39e538d3b41a232035a4a1e240505d Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 23 Nov 2013 20:37:23 +0100 Subject: Add ctrl-click rename to most lists in Blender UI and templates/examples. Notes: * Did not touch to addons, that's up to the authors. ;) * Did not removed any "name" field below lists. We might want to do this in some cases (less UI clutter), but probably not always, so will let maintainers of the related areas decide here. --- doc/python_api/examples/bpy.types.UIList.1.py | 9 ++++++--- doc/python_api/examples/bpy.types.UIList.2.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/python_api/examples/bpy.types.UIList.1.py b/doc/python_api/examples/bpy.types.UIList.1.py index 88f6b0999cd..92b115b2af4 100644 --- a/doc/python_api/examples/bpy.types.UIList.1.py +++ b/doc/python_api/examples/bpy.types.UIList.1.py @@ -32,11 +32,14 @@ class MATERIAL_UL_matslots_example(bpy.types.UIList): ma = slot.material # draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code. if self.layout_type in {'DEFAULT', 'COMPACT'}: - # You should always start your row layout by a label (icon + text), this will also make the row easily - # selectable in the list! + # You should always start your row layout by a label (icon + text), or a non-embossed text field, + # this will also make the row easily selectable in the list! The later also enables ctrl-click rename. # We use icon_value of label, as our given icon is an integer value, not an enum ID. # Note "data" names should never be translated! - layout.label(text=ma.name if ma else "", translate=False, icon_value=icon) + if ma: + layout.prop(ma, "name", text="", emboss=False, icon_value=icon) + else: + layout.label(text="", translate=False, icon_value=icon) # And now we can add other UI stuff... # Here, we add nodes info if this material uses (old!) shading nodes. if ma and not context.scene.render.use_shading_nodes: diff --git a/doc/python_api/examples/bpy.types.UIList.2.py b/doc/python_api/examples/bpy.types.UIList.2.py index 4e30e6895d6..feed263b2e7 100644 --- a/doc/python_api/examples/bpy.types.UIList.2.py +++ b/doc/python_api/examples/bpy.types.UIList.2.py @@ -49,9 +49,9 @@ class MESH_UL_vgroups_slow(bpy.types.UIList): col = layout.column() col.enabled = False col.alignment = 'LEFT' - col.label(text=vgroup.name, translate=False, icon_value=icon) + col.prop(vgroup, "name", text="", emboss=False, icon_value=icon) else: - layout.label(text=vgroup.name, translate=False, icon_value=icon) + layout.prop(vgroup, "name", text="", emboss=False, icon_value=icon) icon = 'LOCKED' if vgroup.lock_weight else 'UNLOCKED' layout.prop(vgroup, "lock_weight", text="", icon=icon, emboss=False) elif self.layout_type in {'GRID'}: -- cgit v1.2.3