Is there a way to register a mousemove event that gets called whenever the mouse moves within the Blender window?


Yes, if you let a Modal Operator run in the background (its modal() needs to return {'PASSTHROUGH'} in order to not consume any events). An event object is passed as third parameter to modal(), which contains the mouse coordinates in window and region space, as well as information about the event itself.

You can react on mouse movements by checking the event.type:

if event.type == 'MOUSEMOVE':
    print(event.mouse_region_x, event.mouse_region_y) # remove 'region_' for window coords!

Have a look at the Operator Modal Draw template in Blender's Text Editor, it illustrates what you can do with the mouse coordinates together with a draw handler and OpenGL (bgl module).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.