[R] Tktable active cell

James Wettenhall wettenhall at wehi.edu.au
Tue Jul 29 02:47:21 CEST 2003

Thomas Sudler <TSudler at ch.imshealth.com> wrote:
> I want to start an action when i click into a cell. Example: 
When I click
> into a cell, a message box should open with the information of 
> location of the cell where I clicked in. <SNIP> So I only
> need to know how to get the possition of the active cell.


Getting the active cell is easy, just use :
row <- tclvalue(tkindex(table1,"active","row"))
col <- tclvalue(tkindex(table1,"active","col"))  

But if you try to catch the left-button-click event and then 
display the cell coordinates in a message box, the problem is 
that your event handler will be run BEFORE the default event 
handler which updates the active cell, so you will get the 
PREVIOUS active cell, (and the first time you will get an 
error because there is no active cell).

The Tcl help for bind :
suggests that you may be able to use a "+" in front of your 
event handler name so that it is "appended to any existing 
binding", but this feature may not be implemented in R Tcl/Tk 
yet, e.g. this didn't seem to work:

tkbind(table1,"<Button 1>",paste("+",.Tcl.callback(onLeftClick),sep=""))


More information about the R-help mailing list