Re: [Fxruby-users] FXTreeList as DND source
Status: Inactive
Brought to you by:
lyle
|
From: Lyle J. <jl...@cf...> - 2003-10-03 15:38:59
|
Dalibor Sramek wrote:
> I would like to make DND source from a FXTreeList. I copied the canvas example
> from Lyle's DND tutorial and replaced the canvas with my FXTreeList. Then I
> found that FXTreeList did not get any SEL_MOTION messages. So is it possible to
> make FXTreeList aDND source in the current FXRuby implementation?
Yes, it is definitely possible to use a tree list (or most any other
widget) as a drag source for DND-aware applications. I apologize that
the DnD tutorial in the FXRuby User's Guide really only scratches the
surface of how to integrate DnD into applications, etc. -- this is a
known shortcoming.
The good news is that for some FOX widgets, including the FXTreeList, a
some of the lower-level details of the DnD protocol are hidden away and
it makes things *slightly* easier than they were for the FXCanvas-based
example used in the tutorial. Since the coordination of
SEL_LEFTBUTTONPRESS, SEL_MOTION and SEL_LEFTBUTTONRELEASE on an
FXTreeList is much more complex than it was for the (basically passive)
FXCanvas widget, the tree list instead sends SEL_BEGINDRAG, SEL_DRAGGED
and SEL_ENDDRAG messages to its target. You will only get these messages
if the user is trying to drag a draggable tree item, and you don't need
to worry about grabbing (or ungrabbing) the mouse, trying to avoid the
autoscroll features of the tree list, etc.
Attached is a replacement for the dragsource.rb example program; per
your request, this one uses a tree list as the source instead of a
canvas. You should be able to use this version of dragsource.rb along
with the dragdrop.rb example (i.e. the drop site) as-is, but this time
you're dragging from tree items with names of colors ("Red", "Green" and
"Blue"). If you drag the "Blue" tree item and drop it on top of
dragdrop.rb's canvas, the canvas should turn blue.
Hope this helps,
Lyle
|