[R-gui] key-binding
James Wettenhall
wettenhall at wehi.edu.au
Wed Dec 10 00:50:24 MET 2003
Thomas,
John has probably answered your question sufficiently already,
but maybe some code like this does what you want:
library(tcltk)
tt <- tktoplevel()
txt <- tktext(tt)
tkpack(txt)
evalSelection <- function() cat(eval(parse(text=tclvalue(tkcmd("selection","get",displayof=txt,type="STRING")))))
tkbind(txt,"<F10>",evalSelection)
The tkbind command says that when F10 is pressed while the text
widget is focused, the R function evalSelection will be run.
I just tried typing
1+1
2+2
3+3
into my text widget, selecting 2+2 and pressing F10, and I got
"4" in my R console. Hopefully it'll work the same for you.
Regards,
James
P.S. The example you quoted from my webpage uses .Tcl and paste
unnecessarily. I really should update some of these examples to
just use tkcmd, tkwidget etc. because these handle "quoting hell"
much better and look nicer.
--------------------------------------------------------------------------
James Wettenhall Tel: (+61 3) 9345 2629
Division of Genetics and Bioinformatics Fax: (+61 3) 9347 0852
The Walter & Eliza Hall Institute E-mail: wettenhall at wehi.edu.au
of Medical Research, Mobile: (+61 / 0 ) 438 527 921
1G Royal Parade,
Parkville, Vic 3050, Australia
http://www.wehi.edu.au
More information about the R-SIG-GUI
mailing list