diff options
author | Jiri Hnidek <jiri.hnidek@tul.cz> | 2012-10-12 22:19:39 +0400 |
---|---|---|
committer | Jiri Hnidek <jiri.hnidek@tul.cz> | 2012-10-12 22:19:39 +0400 |
commit | 13d829e57db6b0bb6ab3c3551676a9fa3bcfd55c (patch) | |
tree | deed370e8f4f125900593493e9b5b7d27c04a243 /doc | |
parent | 1958fda91f8974b6096c7b3427f9af13d26d9dbd (diff) |
* Fix small bug in Python operator example; improved example of modal operator
Diffstat (limited to 'doc')
-rw-r--r-- | doc/python_api/examples/bpy.types.Operator.4.py | 4 | ||||
-rw-r--r-- | doc/python_api/examples/bpy.types.Operator.5.py | 4 |
2 files changed, 5 insertions, 3 deletions
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'} |