diff options
Diffstat (limited to 'release/scripts/templates/operator_modal_draw.py')
-rw-r--r-- | release/scripts/templates/operator_modal_draw.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/release/scripts/templates/operator_modal_draw.py b/release/scripts/templates/operator_modal_draw.py index f1c4e113b0a..d11ddf0b467 100644 --- a/release/scripts/templates/operator_modal_draw.py +++ b/release/scripts/templates/operator_modal_draw.py @@ -42,20 +42,22 @@ class ModalDrawOperator(bpy.types.Operator): self.mouse_path.append((event.mouse_region_x, event.mouse_region_y)) elif event.type == 'LEFTMOUSE': - context.region.callback_remove(self._handle) + bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW') return {'FINISHED'} elif event.type in {'RIGHTMOUSE', 'ESC'}: - context.region.callback_remove(self._handle) + bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW') return {'CANCELLED'} return {'RUNNING_MODAL'} def invoke(self, context, event): if context.area.type == 'VIEW_3D': + # the arguments we pass the the callback + args = (self, context) # Add the region OpenGL drawing callback # draw in view space with 'POST_VIEW' and 'PRE_VIEW' - self._handle = context.region.callback_add(draw_callback_px, (self, context), 'POST_PIXEL') + self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL') self.mouse_path = [] |