Updated 2013-09-17 22:13:56 by RLE

AJB - Background: Having a touchpad can be very useful in X-windows. With the proper drivers you get a handful of controlable mouse gestures that map to button bindings. Examples: Punch down with a single finger on the pad for a Button-1 event, Two fingers at the same time for a Button-2 event, Three fingers for Button-3 (Only 3 of my fat fingers fit on the pad, but it should be possible to do more). Also, and most useful, sliding your finger up and down on the left vertical edge of the pad generates Button-4 and Button-5 events, depending on direction, and these map out just fine. The problem comes with the bottom edge of the pad that is mapped to Button-6 and Button-7 events. However, X.h does not, and can not, define a Button6MotionMask or Button7MotionMask. Which the current Tk code relys on :( So, with a bit of help from RS on the chat here is a solution to the problem.
 bind . <Button> {if {"%b" eq 6} {puts left} elseif {"%b" eq 7} {puts right}}

This works because the %b will report the numbers back correctly, even though <Button-6> or <Button-7> event bindings are invalid.

I hope that there is a better solution coming one day. I understand that the X people were able to define <Btn6Up> and <Btn6Down> events, maybe that could be used to incorporate these into the core? I really don't no enough about it to tell, but I did no enough to get this far. Frustrating.

Thanks to RS for added guidance at the end.

Martyn Smith Its a shame this does not work on windows (maybe with TWAPI) I just tried it with my Logitech mouse to add the 6, 7, 8 and 9 buttons (the wheel moves left(6) and right(7) and there are two side back(8) and forward(9) buttons) and it works great.