From 13d829e57db6b0bb6ab3c3551676a9fa3bcfd55c Mon Sep 17 00:00:00 2001 From: Jiri Hnidek Date: Fri, 12 Oct 2012 18:19:39 +0000 Subject: * Fix small bug in Python operator example; improved example of modal operator --- doc/python_api/examples/bpy.types.Operator.4.py | 4 ++-- doc/python_api/examples/bpy.types.Operator.5.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/python_api/examples/bpy.types.Operator.4.py b/doc/python_api/examples/bpy.types.Operator.4.py index 861496c6d18..885ed857842 100644 --- a/doc/python_api/examples/bpy.types.Operator.4.py +++ b/doc/python_api/examples/bpy.types.Operator.4.py @@ -26,8 +26,8 @@ class CustomDrawOperator(bpy.types.Operator): return {'FINISHED'} def invoke(self, context, event): - context.window_manager.fileselect_add(self) - return {'RUNNING_MODAL'} + wm = context.window_manager + return wm.invoke_props_dialog(self) def draw(self, context): layout = self.layout diff --git a/doc/python_api/examples/bpy.types.Operator.5.py b/doc/python_api/examples/bpy.types.Operator.5.py index e123768431b..4a0abcb62c3 100644 --- a/doc/python_api/examples/bpy.types.Operator.5.py +++ b/doc/python_api/examples/bpy.types.Operator.5.py @@ -40,15 +40,17 @@ class ModalOperator(bpy.types.Operator): elif event.type == 'LEFTMOUSE': # Confirm return {'FINISHED'} elif event.type in ('RIGHTMOUSE', 'ESC'): # Cancel + context.object.location.x = self.init_loc_x return {'CANCELLED'} return {'RUNNING_MODAL'} def invoke(self, context, event): + self.init_loc_x = context.object.location.x self.value = event.mouse_x self.execute(context) - print(context.window_manager.modal_handler_add(self)) + context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} -- cgit v1.2.3