From 0e3d637ad040f55412856d10197f66f166591e49 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 20 Dec 2012 13:29:58 +0000 Subject: Change region drawing callbacks to work much closer to how blender manages them internally. - yes, this does break scripts, but the api is marked experimental. ED_region_draw_cb_activate() adds a callback to a region type whereas the api made it look like the callback was being added to the region instance. Use a class method on bpy.types.Space to manage region drawing, eg. was: self._handle = context.region.callback_add(draw_callback_px, args, 'POST_PIXEL') is now: self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL') --- release/scripts/templates/operator_modal_draw.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'release') 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 = [] -- cgit v1.2.3