Sebastian P. Luque <spluque <at> gmail.com> writes: > > Hi again, > > Reading the vignette("gWidgets") and the RNews article, which show > arguments 'h', and '...' for handler functions that update an embedded > plot. However, it's not clear what these arguments are doing, and if I > leave the latter out of my handler function (also a plot updater), I get > the following error: > > Error in handler(...) : > unused argument(s) (list(obj = <S4 object of class "gSliderRGtk">, action = NULL), <pointer: 0x3bf8e60>) > > as soon as I change any slider, etc. What are these arguments for? > Thanks! > > Cheers, >
The handlers in the various toolkits have several different arguments, none of course being standard. The ... is to accommodate these. Whereas, the first argument for a handler, called "h" from the iWidgets background of gWidgets, is a list containing components "obj" to refer to the object that the handler is called on, such as the slider in your example, and "action" which just passes along the action= argument. (Some widgets have additional components, such as "dropdata" or "x" and "y".) The h$obj construction allows you to avoid global variables. So the following are equivalent: sl = gslider(cont=gwindow(), handler = function(h,...) print(svalue(sl))) and sl = gslider(cont=gwindow(), handler = function(h,...) print(svalue(h$obj))) Hope that clarifies the situation. --John _______________________________________________ R-SIG-GUI mailing list R-SIG-GUI@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-gui