mouse bind

pack [canvas .c -bg yellow] -fill both -expand yes
bind .c <Button-1> {puts 1}
bind .c <Button-2> {puts 2}
bind .c <Button-3> {puts 3}
bind .c <Button-4> {puts 4}
bind .c <Button-5> {puts 5}

Button-1    left mouse click

Button-2    Middle mouse click

Button-3    Right mouse click

Button-4    Middle mouse up

Button-5    Middle mouse down

bind .c <ButtonPress-1> {puts 1}
bind .c <ButtonPress-2> {puts 2}
bind .c <ButtonPress-3> {puts 3}
bind .c <ButtonPress-4> {puts 4}
bind .c <ButtonPress-5> {puts 5}

pack [canvas .d -bg green] -fill both -expand yes
bind .c <Control-Motion> {puts 1}
bind .c <Control-Shift-Motion> {puts 2}
bind .c <Leave> {puts 3}
bind .c <Control-ButtonPress-1> {puts 4; focus .c}
bind .c <Control-Shift-ButtonPress-1> {puts 5; focus .d}
bind .c <FocusIn> {puts 6}
bind .c <FocusOut> {puts 7}
bind .c <KeyPress> {puts 8}
bind .c <KeyPress-Control_R> {puts 9}
bind .c <KeyRelease-Control_L> {puts 10}

原文地址:https://www.cnblogs.com/greencolor/p/2155522.html