Mark Heckmann <mark.heckmann <at> gmx.de> writes: > > I got stuck while trying to implement Drag and Drop in gwidgets. > I hoped the following code would call the handler function and thus > print something to the console. > But it does not. ISo suppose I do not understand some basic > properties of the handler mechanism. > Can someone explain? >
Mark, it should, but doesn't. I couldn't figure out how to get dnd with the gedit widget to work properly (it would drop the value twice). What yo have works with other widgets. However, it shouldn't be so hard. Below I show how to do this through RGtk2, a fix I'll put on my todo list for the package: library(gWidgets) options(guiToolkit="RGtk2") w <- gwindow() g <- ggroup(cont=w) lab = glabel("drag me",container=g) ed = gedit("drop here",container = g) adddropsource(lab) ## do this: library(RGtk2) gSignalConnect(getToolkitWidget(ed), "drag-data-received", f=function(w,...) { print("arrived") val <- w$getText() svalue(ed) <- val }) --John > w <- gwindow() > lab = glabel("drag me",container=w) > ed = gedit("drop here",container = w) > adddropsource(lab) > adddroptarget(ed, handler=function(h,...) print("arrived")) > > Thanks, > Mark > > ––––––––––––––––––––––––––––––––––––––– > Mark Heckmann > Dipl. Wirt.-Ing. cand. Psych. > Vorstraße 93 B01 > 28359 Bremen > Blog: www.markheckmann.de > R-Blog: http://ryouready.wordpress.com > _______________________________________________ R-SIG-GUI mailing list R-SIG-GUI@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-gui