Changeset View
Changeset View
Standalone View
Standalone View
doc/python_api/examples/bpy.types.Operator.6.py
| Show All 25 Lines | class SearchEnumOperator(bpy.types.Operator): | ||||
| def execute(self, context): | def execute(self, context): | ||||
| self.report({'INFO'}, "Selected:" + self.my_search) | self.report({'INFO'}, "Selected:" + self.my_search) | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| def invoke(self, context, event): | def invoke(self, context, event): | ||||
| context.window_manager.invoke_search_popup(self) | context.window_manager.invoke_search_popup(self) | ||||
| return {'RUNNING_MODAL'} | return {'RUNNING_MODAL'} | ||||
| # Only needed if you want to add into a dynamic menu | |||||
| def menu_func(self, context): | |||||
| self.layout.operator(SearchEnumOperator.bl_idname, text="Search Enum Operator") | |||||
| # Register and add to the object menu (required to also use F3 search "Search Enum Operator" for quick access) | |||||
lichtwerk: please add the //(required to use F3 search....// part here as well | |||||
| bpy.utils.register_class(SearchEnumOperator) | bpy.utils.register_class(SearchEnumOperator) | ||||
| bpy.types.VIEW3D_MT_object.append(menu_func) | |||||
| # test call | # test call | ||||
| bpy.ops.object.search_enum_operator('INVOKE_DEFAULT') | bpy.ops.object.search_enum_operator('INVOKE_DEFAULT') | ||||
please add the (required to use F3 search.... part here as well