[Gambas-user] a few drag and drop questions

Nick nick.mele at ...626...
Fri Jul 29 21:47:22 CEST 2005


Hello- 

I'm new to this mailing list, and new to gambas, so I hope I'm not
being redundant (I've already searched the docs and mailing list
archives). I'll include a link to my source at the end of this mail.

My firsty question deals with this sub:

PUBLIC SUB TreeView1_MouseMove()
  IF Mouse.Left AND TreeView1.Available THEN
    IF TreeView1.Find(Mouse.ScreenX - TreeView1.ScreenX, Mouse.ScreenY
- TreeView1.ScreenY) THEN
      RETURN
    ENDIF
    Drag.Icon = tm.nodePicture
    TreeView1.Current.Selected = TRUE
    TreeView1.Drag(TreeView1.Key, Drag.Text)
  ENDIF
END

...ok, this is the sub that initiates the drag... at first i tried to
do this within the event handler TreeView1_MouseDown(). This doesn't
seem to work; TreeView1.Find should set the treeview's internal cursor
to the node that the mouse was over,  TreeView1.Current.Selected =
TRUE should select the node, so that TreeView1.Key is the key of the
node the mouse was over... but instead, TreeView1.Key is the key of
the last node that was selected.Could this be a bug, or am i just
doing it wrong?

second question - 

PUBLIC SUB TreeView1_Drag()
  TreeView1_DragMove()
END
PUBLIC SUB TreeView1_DragMove()
  IF Drag.Source <> TreeView1 OR TreeView1.Find(Drag.X, Drag.Y) THEN
    STOP EVENT
  ELSE
    TreeView1.Item.Selected = TRUE
  ENDIF
END

This restricts the treeview to be it's own only drop target, only when
there's a node under the mouse. It seems to work fine, except for one
thing... if you drag a node and let it go somewhere on the tree, not
on another node, or if you try to drag something external to the
application onto the control, you lose the ability to initiate a new
drag event! The tree nodes are not draggable again until the right
mouse button is clicked (which shows a context menu in my
application.) Any suggestions on this?

One more small question having nothing to do with drag and drop:
What's my best bet for creating a rich text editor control? Inheriting
from either TextView or TextArea, or using a DrawingArea with a
buffer, or something else, or just wait for someone to write one in C?

Here's a link to the application so far.. any other suggestions are
welcome too; just keep in mind this is the product of only a few days
of intermittant work, so don't judge too harshly =)

http://www.freepgs.com/ufo/nick/treenote.tar.gz

Thanks in advance for any advice.
--Nick




More information about the User mailing list