After seeing bpy.types.Event https://docs.blender.org/api/current/bpy.types.Event.html, and some code examples, I cannot find the event of leftmouse up, only LEFTMOUSE is available. (correct me if it is wrong)

I want to ask how to capture the leftmouse up event using python. Thanks.


1 Answer 1


As mentioned in the document, the Event.type will tell you which key or mouse button sent the event and the Event.value specifies if pressing or releasing happened.

So you can do something like below in the modal method of an operator for example:

Here ctx is the current context in Blender and the evt is bpy.types.Event instance

def modal(self, ctx, evt):
    if evt.type == 'LEFTMOUSE':
        if evt.value == 'PRESS':
            print('LMB Pressed')
        elif evt.value == 'RELEASE':
            print('LMB Released')
    return {'RUNNING_MODAL'}

A thorough example of using modal event handler is at the link below.



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .