Searchable EnumProperty #118004
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#118004
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Issue
EnumProperty is very useful when displaying a human-readable name for an item as the value/name, and a machine-readable key/identifier that is used in code.
Currently, EnumProperty only supports non-searchable lists, a workaround is to use a StringProperty with a search, and a custom getter/setter that reads the human-readable input string finding the matching machine-readable key/identifier to store in another property.
Work Around
An example of this is in the Blender Kitsu Add-On, users are required to select a Task Type from a list, this task type has a human read-able value/name, and a machine-readable key/identifier that is stored in the add-on. An implementation of the above workaround can be found in the add-on's props.py file.
A challenege with this workaround is that the developer needs to ensure that these two values are always in sync with each-other.
Solution
Add a search property to the EnumProperty could make the above implementation a lot simpler and more reliable.
EnumProperty should be used so a user can select a value/name, and accessing that property via python returns the key/identifier. This list should be searchable, so users can quickly find the value/name they need without scrolling a large list.
API
The search_options set does NOT include the
’SUGGESTION’
flag found in StringProperty search_options because users can ONLY enter values found in search candidates, otherwise cancel the user's input.UI
The UI could be very similar to the StringProperty search, where a text field when selected draws a list. In the case of EnumProperty this list would contain only the names of the enum items list. A user can select the desired name/value, then accessing this property via python would return the matching key/identifier.
@fsiddi as requested here is the proposal for searchable enums, please let me know your feedback.
Another workaround is using an operator with
WindowManager.invoke_search_popup()
: https://docs.blender.org/api/current/bpy.types.Operator.html#enum-search-popupThe main issues with the operator setup are having to define and register a separate operator for every enum that should be searchable and that it can sometimes be complicated to set the desired enum property from the current context in
execute()
.Also, from a UI standpoint (and there might be a way around this that I don't know about), it doesn't look great because operators are drawn as buttons.
Adding the ability to search an enum seems fine.
There are a few things to consider but overall I think the tradeoffs are acceptable.
@Mysteryem That is a great point, from a UI design perspective I know that @fsiddi didn't love that solution, I believe because it appears to be an operator and not a field where a user should select something, (but I will let him explain that further), this change was made in studio/blender-studio-pipeline#187. In that PR you can see the new vs old UI
@ideasman42 Thanks for your feedback!
I agree not animated is probably fine in this context. I would like to propse another UI (pictured below) that would be more consistent visually with the existing enum property UI.
[(identifier, name, description, icon, number)]
for each itemThis would also solve part of the issues discussed in #117711 (#93814)
The design proposed by @TinyNick looks good. This was also discussed with @JulianEisel. Perhaps @Harley has time to look into this?
I've added this to the agenda of our module meeting on Tuesday.