where to hold mouse button state in Tkinter?

Fredrik Lundh effbot at telia.com
Sun Feb 27 06:16:55 EST 2000


Pedro Jones <calroc at mindspring.com> wrote:
> I'm writing a widget that needs to detect in it's callback for a
> <Button-1> event whether or not one or both of the other mouse buttons
> are pressed and take different actions depending. What's a good way to
> access mouse state of the other buttons in the callback for one? Does
> Tk/Tkinter provide something easy I've overlooked?

the event instance has a "state" member which reflects
the state of modifier keys and mouse buttons.

iirc, the relevant bitmasks are:

    Button1Mask = 1<<8
    Button2Mask = 1<<9
    Button3Mask = 1<<10

hope this helps!

</F>





More information about the Python-list mailing list