[Lazarus] Generalized DragDrop

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sun Jan 23 01:21:23 CET 2011


Michael Van Canneyt schrieb:

>> In fpGUI Graeme implemented an interface for inter-process dragging. 
>> It would be nice to have a similar interace in the LCL, that extends 
>> the current intra-process dragging.
> 
> While it is correct that Graeme did this, I still have not seen in action.
> i.e. I have used the application-specific DnD, but I wouldn't know how 
> to handle the intra-app DnD.

Simply start the demo app twice, then drag...


> I'm all for it. Although I'm not sure that this can be implemented in a 
> cross-platform way.
> 
> On Windows, the intra-app drag/drop is handled using OLE/DDE. On Linux, 
> there is no such thing, and I think it depends on the used desktop 
> software (KDE vs Gnome).
> I don't know how it is done in Mac.

I think that Graeme can answer this question...


> But your suggestion is at least a step in the right direction.
> 
> I would implement support in 2 objects: TFileDragObject (external files, 
> as dropped by file managers)
> TExternalDragObject (external app DnD)
> Both are created whenever an external DnD is found.

I'd leave all that to the concrete implementations, and provide 
specialized handlers in the target controls. Currently 
TControl.DoDragMsg dispatches the messages to the Drop and Dock methods, 
based on the DragObject class type. More handlers can be added, and 
dispatch may be rebased on a drag type (enum) property.


> Putting everything in the base class is IMHO not necessary, and only 
> complicates things.

The base class (TDragObject) only must declare the extended API, 
including common properties. It also will introduce the virtual methods, 
required at the begin, during dragging, and on an drop. Actually the 
drag performer API can be moved from TDragDockCommon into TDragObject, 
and its implementation (of internal dragging) into TDragControlObject 
and TDragDockObject.

DoDi





More information about the Lazarus mailing list