[lazarus] Drag and Drop - The Saga Continues

Shane Miller SMiller1 at stvgb.org
Fri Apr 7 10:41:38 EDT 2000

OK, I want to start this discussion on Drag and Drop before coding it.

My idea's on how Drag and Drop can be implemented.  

Method 1:  By tracking the MouseMOve and MouseDown and MouseUp messages we can implement drag and drop within the LCL.  When the Mouse Button is pressed and a move occus we set a global "Dragging" flag along with a "draggingcontrol" flag or something to track within what control the dragging began.
If the mouse button is lifted and the mouse is within a control other than the "draggingcontrol" control then we know they are attempting to do a drag_drop.  This is a very simplified explanation.

Method 2:  Starting with GTK, it is already built into the widgets.  So, when dragging begins a signal occus "drag_start" (or something like that).  We can set up message methods

Procedure DragStart(var msg TDragMsg) ; message LM_DRAGSTART;
Procedure DragStart(var msg TDragMsg) ; message LM_DRAGDROP;
Procedure DragStart(var msg TDragMsg) ; message LM_DRAGMOVE;

and track the dragging there.  Each widget sset would have to handle the dragging themselves.  This would be the easier of the two as long as the widget sets each support certain things like these "drag messages" and such.

What is everyone's thought?  I have implemented it both ways so far.  The first is quite a bit more involved but it's similiar to the method used in Delphi. However, that's not needed in this case.  By remaining similiar to Delphi in this case gains us nothing so that should not be a deciding factor.


More information about the Lazarus mailing list