forked from bartvdbraak/blender
minor changes to templates
This commit is contained in:
parent
cb8d53efcc
commit
383da79d63
@ -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'}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user