[Bf-blender-cvs] [65d40b3eeb8] master: Docs: invoke_search_popup uses bl_property
Campbell Barton
noreply at git.blender.org
Fri Jan 26 01:55:01 CET 2018
Commit: 65d40b3eeb8bd92ec74a2c3c03c73a331dccf668
Author: Campbell Barton
Date: Fri Jan 26 11:52:01 2018 +1100
Branches: master
https://developer.blender.org/rB65d40b3eeb8bd92ec74a2c3c03c73a331dccf668
Docs: invoke_search_popup uses bl_property
Also add code example in docs.
===================================================================
A doc/python_api/examples/bpy.types.Operator.6.py
M source/blender/makesrna/intern/rna_wm_api.c
===================================================================
diff --git a/doc/python_api/examples/bpy.types.Operator.6.py b/doc/python_api/examples/bpy.types.Operator.6.py
new file mode 100644
index 00000000000..d32a7d5fd4a
--- /dev/null
+++ b/doc/python_api/examples/bpy.types.Operator.6.py
@@ -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')
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 089504e342a..cbbe50ccf03 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -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 */
More information about the Bf-blender-cvs
mailing list