The following R code works as expected:
require( tcltk )
tt <- tktoplevel()
# create a button labelled A that changes to B when pressed
pressed <- function() tkconfigure( tt.but, text="B" )
tt.but <- tkbutton( tt, text="A", command=pressed )
tkpack(tt.but)
# if Control-Button-1 pressed change button label to C
e <- expression( tkconfigure( tt.but, text="C" ), break )
tkbind(tt.but, "<Control-Button-1>", e )
But if I simply replace Control-Button-1 with Button-2 in the tkbind
command, i.e. the last line, then nothing happens when I press
Button-2 (which I assume is the right mouse button).
I also tried removing the break and using a function instead of an
expression but it also does not respond, i.e. I tried replacing
the last line with:
tkbind(tt.but, "<Button-2>", function() tkconfigure( tt.but,
text="C" ) )
I am using Windows 2000 and R 1.8.1 and am pasting the script
into Rterm to make sure that the Rgui does not interfere with it.