minor changes to templates

This commit is contained in:
Campbell Barton 2013-10-22 00:25:15 +00:00
parent cb8d53efcc
commit 383da79d63
2 changed files with 6 additions and 4 deletions

@ -9,7 +9,7 @@ class ModalTimerOperator(bpy.types.Operator):
_timer = None _timer = None
def modal(self, context, event): def modal(self, context, event):
if event.type == 'ESC': if event.type in {'RIGHTMOUSE', 'ESC'}:
return self.cancel(context) return self.cancel(context)
if event.type == 'TIMER': if event.type == 'TIMER':
@ -21,12 +21,14 @@ class ModalTimerOperator(bpy.types.Operator):
return {'PASS_THROUGH'} return {'PASS_THROUGH'}
def execute(self, context): def execute(self, context):
self._timer = context.window_manager.event_timer_add(0.1, context.window) wm = context.window_manager
context.window_manager.modal_handler_add(self) self._timer = wm.event_timer_add(0.1, context.window)
wm.modal_handler_add(self)
return {'RUNNING_MODAL'} return {'RUNNING_MODAL'}
def cancel(self, context): def cancel(self, context):
context.window_manager.event_timer_remove(self._timer) wm = context.window_manager
wm.event_timer_remove(self._timer)
return {'CANCELLED'} return {'CANCELLED'}