Docs: invoke_search_popup uses bl_property
Also add code example in docs.
This commit is contained in:
parent
da4c3f30d9
commit
65d40b3eeb
Notes:
blender-bot
2023-02-14 08:38:11 +01:00
Referenced by issue #54092, "save buffers" option seams to apply color correction twice while rendering Referenced by issue #53683, 2.79a release Referenced by issue #53003, VSE: mp4/video won't work with mp3/audio
|
@ -0,0 +1,38 @@
|
|||
"""
|
||||
Enum Search Popup
|
||||
+++++++++++++++++
|
||||
|
||||
You may want to have an operator prompt the user to select an item
|
||||
from a search field, this can be done using :class:`bpy.types.Operator.invoke_search_popup`.
|
||||
"""
|
||||
import bpy
|
||||
from bpy.props import EnumProperty
|
||||
|
||||
|
||||
class SearchEnumOperator(bpy.types.Operator):
|
||||
bl_idname = "object.search_enum_operator"
|
||||
bl_label = "Search Enum Operator"
|
||||
bl_property = "my_search"
|
||||
|
||||
my_search = EnumProperty(
|
||||
name="My Search",
|
||||
items=(
|
||||
('FOO', "Foo", ""),
|
||||
('BAR', "Bar", ""),
|
||||
('BAZ', "Baz", ""),
|
||||
),
|
||||
)
|
||||
|
||||
def execute(self, context):
|
||||
self.report({'INFO'}, "Selected:" + self.my_search)
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
context.window_manager.invoke_search_popup(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
|
||||
bpy.utils.register_class(SearchEnumOperator)
|
||||
|
||||
# test call
|
||||
bpy.ops.object.search_enum_operator('INVOKE_DEFAULT')
|
|
@ -459,8 +459,11 @@ void RNA_api_wm(StructRNA *srna)
|
|||
|
||||
/* invoke enum */
|
||||
func = RNA_def_function(srna, "invoke_search_popup", "rna_Operator_enum_search_invoke");
|
||||
RNA_def_function_ui_description(func, "Operator search popup invoke (search in values of "
|
||||
"operator's type 'prop' EnumProperty, and execute it on confirmation)");
|
||||
RNA_def_function_ui_description(
|
||||
func,
|
||||
"Operator search popup invoke which "
|
||||
"searches values of the operator's :class:`bpy.types.Operator.bl_property` "
|
||||
"(which must be an EnumProperty), executing it on confirmation");
|
||||
rna_generic_op_invoke(func, 0);
|
||||
|
||||
/* invoke functions, for use with python */
|
||||
|
|
Loading…
Reference in New Issue