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 ofthe> location of the cell where I clicked in. <SNIP> So I only > need to know how to get the possition of the active cell.Thomas, 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 : http://aspn.activestate.com/ASPN/docs/ActiveTcl/ActiveTcl8.4.1.0-html/tcl/TkCmd/bind.htm 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="")) Regards, James
Thomas Sudler <TSudler at ch.imshealth.com> wrote:> color of all the cells, that's no problem. But is it alsopossible to define> another color for different cells? (example: Cell at position[1,1]:red, Thomas, Try this: require(tcltk) tclRequire("Tktable") tt <- tktoplevel() table1 <- tkwidget(tt,"table") tkpack(table1) tkcmd(.Tk.ID(table1),"tag","celltag","ZeroZero","0,0") tkcmd(.Tk.ID(table1),"tag","celltag","ZeroOne","0,1") tkcmd(.Tk.ID(table1),"tag","configure","ZeroZero",bg="red") tkcmd(.Tk.ID(table1),"tag","configure","ZeroOne",bg="blue") Regards, James> Thank you very much for your answer. It works great. > Thomas.