[fxruby-users] FXRuby app

Lyle Johnson lyle.johnson at gmail.com
Mon Jun 11 13:01:04 EDT 2007

On 6/11/07, Connelly, Stephen <sconnell at harris.com> wrote:

> I'm trying to write some FXRuby code that is similar to a Tcl/Tk example in
> John Ousterhout's Tcl/Tk book.  This code allows the user to create a "ball
> and stick" graph using nodes and edges.  The part that is troubling me is
> the capability to drag nodes in the canvas.

Quick note: FOX's Canvas widget is just a basic drawing area, and is
not really anything like the venerable Tk Canvas widget.

> I have a start on the FXRuby code that uses some of your
> DragDropWindow example.  I need to replace the FXWindow.colorType with
> something else in  order to drag and drop the rectangles that I am using as
> nodes.  I tried FXWindow.rectType and FXWindow.rectangleType.  Neither of
> these attempts worked.  Perhaps the drag and  drop paradigm is not what
> should be used here.  Can you advise me?

The FXWindow.colorType is a built-in, predefined drag type. Generally
speaking, you'd need to define your own application-specific drag type
for something like a "rectangle" drag type. The "Working with the
Clipboard" tutorial talks about how to do this.

Having said that, I don't believe that drag and drop is really
applicable for what you're trying to do anyways. FOX's drag and drop
support primarily facilitates data transfer between windows or
applications; it's probably overkill for what you're doing. I think
you'd probably want to focus on handling the SEL_LEFTBUTTONPRESS,
SEL_LEFTBUTTONRELEASE and SEL_MOTION messages from the FXCanvas to
keep track of where the user is "dragging" whatever it is that they
clicked on. That of course means that you'll need to do hit testing
(to figure out what it is that they clicked on in the first place),

Hope this helps,


More information about the fxruby-users mailing list