Forum: Ruby-Gnome 2 Visualruby Now has Drag and Drop

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
C37e335e7250698ebcc8a092a4baded3?d=identicon&s=25 Eric C. (eric_c)
on 2012-11-28 10:12

I've just added drag and drop to visualruby.  I isn't documented on yet, but there is an example program in the latest
visualruby gem (0.1.2).  Its pretty simple.  You can do this:

label1 ="Hello World")
label2 ="Goodbye")
button1 ="I need a Label")


Then you write a method for the action you want it to take:

def button1__drag_drop(*args)
  source_label = button1.dragged_widget
  button1.label = source_label.label

The instance variable, dragged_widget is added by visualruby in the drag
process.  It holds a reference to the source widget.

Note: the method must be use the naming convention "widget__signal"

I'd like to hear input from you guys because I'm taking a very simple
approach:  dragging one widget onto another then writing a handler.  It
looks like the best solution to me.  GTK has special drag-n-drop stuff
so you can drag treeview rows around, but I can't get it to copy/move
records from one treeview to another:

To see this work, go to, and download it using the
instructions.  Open the "drag_drop" example.

Also, the program was having a problem on some machines when it scanned
the "home" directory for project files because some people had thousands
of files in their home directory causing a big pause.  To correct this,
the program now creates a folder:  home/visualruby  to narrow the
search.  However, now everyone will basically be required to keep all
their projects in the home/visualruby folder.  Let me know if this is a

Eric C
This topic is locked and can not be replied to.