does anyone know how to make a modal do something different if i have a key held? This is what i have at the moment:
if event.type == 'MOUSEMOVE':
if event.type == 'LEFT_SHIFT' and event.value == 'PRESS':
self.value = (event.mouse_region_x - self.mouse_x_initial)
print(self.value)
self.value = event.mouse_region_x - self.mouse_x_initial
The event
parameter has boolean properties for ctrl
, alt
, shift
and oskey
. Test these to know if one of the keys is being held at the time of the event.
def modal(self, context, event):
if event.type == 'MOUSEMOVE':
if event.ctrl:
print('Ctrl is down')
if event.shift:
print('shift is down')
if event.alt:
print('alt is down')
elif event.type == 'ESC':
return {'CANCELLED'}
return {'RUNNING_MODAL'}
As the boolean properties don't distinguish between left and right keys, you would need to keep a record of the previous event and also check that to know which action to take if you wanted them to work differently.