[R] gWidgets / RGtk2 - how to change a handler from a toolbar?

john verzani jverzani at gmail.com
Mon Dec 28 03:19:46 CET 2009


Mark Heckmann <mark.heckmann <at> gmx.de> writes:

> 
> 
> I want to assign a default handler to a toolbar button and change the  
> handler later.
> The addhandlerclicked() method does not apply to a gAction Object, I  
> think...
> 
> defHandler <- function(h, ...) print("default")	
> w <- gwindow()			
> aTest <-  gaction(label="Test", icon="open", handler=defHandler)
> tblList = list( test = aTest )
> toolBar = gtoolbar(tblList, cont=w)
> 

There should be a method to do this, but for now there isn't. A workaround would
be to have the default handler call a function which can be redefined during the
flow of the program:

f <- function(h,...) print("default")
defHandler <- function(h, ...) f(h,...)

The RGtk2 way would be to remove the handler and add a new one, but even that
isn't so easy, as the id isn't stored at the moment.

--John

> At this point I would like to change the handler from the aTest object.
> Does someone know?
> 
> TIA
> Mark
> 
> –––––––––––––––––––––––––––––––––––––––
> Mark Heckmann
> Dipl. Wirt.-Ing. cand. Psych.
> Vorstraße 93 B01
> 28359 Bremen
> Blog: www.markheckmann.de
> R-Blog: http://ryouready.wordpress.com
> 
>




More information about the R-help mailing list