AW: [R-gui] key-binding

"Unternährer Thomas, uth" uth at zhwin.ch
Wed Dec 10 10:05:05 MET 2003


Thanks a lot to james wettenhall an john fox for their hints and comments.
It works fine now.
 
Thomas
 
 
 
 
 

	-----Ursprüngliche Nachricht----- 
	Von: James Wettenhall [mailto:wettenhall at wehi.edu.au] 
	Gesendet: Mi 10.12.2003 00:50 
	An: Unternährer Thomas, uth 
	Cc: r-sig-gui at stat.math.ethz.ch 
	Betreff: Re: [R-gui] key-binding
	
	

	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