[Lazarus] Generalized DragDrop

Hans-Peter Diettrich DrDiettrich1 at aol.com
Mon Jan 24 11:27:31 CET 2011


Graeme Geldenhuys schrieb:
> Op 2011-01-23 22:09, Hans-Peter Diettrich het geskryf:
>> Either different applications have to agree about
>> exchangable data formats,
> 
> What's wrong with that? That is exactly what *all* DND implementation
> do! The Source of the DND action supplies a list of data types they
> support, the target goes through the list and if they don't understand
> any of the data types then DND (data exchange) cannot happen.

The Delphi dragging model is strictly internal, independent from global 
conventions.

> Dragging selected text from Wordpad to Notepad (on my Win2000 system) is
> not possible (yet dragging a text file is). So clearly Notepad limits
> what it will accept, looking for a very specific data format, and not
> even supporting CF_TEXT data.

We should make *something* work first, then look into special cases. The 
reaction of applications is widely application specific, and implies no 
rule how other applications should handle various kinds of dropped items.


>> or a single application needs only private
>> types, for strictly private use.
> 
> correct again. If I want to limit what data my apps or components must
> accept, then I'll add some application specific mime-type which only my
> other apps will probably support. This is pretty normal DND
> functionality on any platform.

It depends on the control type *and* its role in an application, what it 
should accept. An editor control can accept all kinds of text, and 
possibly graphics, while a file list will only accept file references. 
It's up to the control's drag handlers to check the dragged item(s), and 
to react accordingly.

> Saying that, most apps at least allow some form of "plain text" data too
> - as a fallback. But that is not a giving rule in DND. Se my earlier
> paragraph of Notepad.

Plain text is a standard case, that should be supported by the component 
library. But no control is obliged to accept text at all.

>> Every data type must be associated with a class (or component),
> 
> It's not possible between applications. Why would WordPad know what a
> TMemo or TEdit is? So you MUST supply the data in some byte array (this
> depends on the platform), or simply supply the URI in case of a file(s),
> so the target can read that file directly if they wanted.

I didn't mention specific control types, but only classes that implement 
support for specific data formats, like HTML, XML, JPEG...


>> Did you realize that URI lists are meaningful only to applications, that
>> can handle the referenced resources - in their specific data format,
>> that is not part of the URI. Otherwise the only use of such information
>> is textual display of the URIs themselves, that does not require any
>> special conversion.
> 
> I'm not sure I understand the point your are trying to make. I can say
> that 'text/uri-list' could simply be a "fallback" data type. Normally
> the source of DND has a list of data formats, and normally they are in
> "most specific" to "least specific" order. Take Gnome's Nautilus (file
> manager) as an example. It supplies 8 data formats when dragging files.
> The first being something I guess only Gnome applications will
> understand. Then the format list becomes less and less specific,
> 'text/uri-list' being the second choice of data types.

It's up to the drop target to select whatever data format is appropriate 
for its operation, in a specific application.

> See attached screenshot.
> 
> 
>> Okay, Firefox works - but why then do you not simply show the CF_TEXT or
>> CF_UNICODETEXT format?
> 
> It does. See the 'firefox_dnd.png' attachment. And as you can see, it is
> also not the "preferred" format for Firefox, as CF_TEXT is listed number
> 6 only.

The preferences of Firefox are quite unimportant to a target in a 
different application.

DoDi





More information about the Lazarus mailing list