[Lazarus] Generalized DragDrop

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


Graeme Geldenhuys schrieb:
> On 23 January 2011 03:16, Hans-Peter Diettrich <DrDiettrich1 at a*****> wrote:
>> Clipboard formats (CF_...) may be usable on all platforms with a
>> comparable/compatible clipboard functionality. But what about all the other
>> platforms?
> 
> As I mentioned, fpGUI uses mime-types. More and more platforms are
> starting to use mime-types too - a natural evolution (considering the
> success in emails).

That's okay for data files, but not necessarily sufficient for draggable 
objects in general.

> fpGUI will register the mime-types, and if a
> similar platform specific type exists, fpGUI will automatically
> register that format too (eg: mime-type 'text/plain'  under Windows
> will automatically also have the CF_TEXT type registered). For each
> platform fpGUI supports, I simply need to override and implement
> platform specific DND/Clipboard types too (not replacing the
> mime-types though).

Such a *definition* of types doesn't make any sense to me, in DND or 
clipboard context. Either different applications have to agree about 
exchangable data formats, or a single application needs only private 
types, for strictly private use.

>> Your current implementation is restricted to purely textual information,
> 
> Simply because I was in a rush to implement the basic workings of DND
> for a new project of ours. Textual information was good enough to get
> that app's DND going. The DND does does lend itself to other data
> types too. Any binary data will simple be transfered via bytes, and
> internal component-to-component DND could possible also support
> TStream data.
> This is one of the optimizations that can be implemented for internal app DND.

This is not a matter of optimization, it's a matter of specialization. 
Every data type must be associated with a class (or component), that 
*interprets* the data in the intended way. All you need is a 
*registration* system for such classes.


>> I'm not sure whether your implementation of rich (html...) text will match
>> the platform standards - with possibly different standards on every single
>> platform :-(
> 
> Once I'm done with the complete DND implementation in fpGUI, the
> developer can register for example HTML data via 'text/html', but can
> retrieve 'text/plain' data (all HTML tags stripped) without any extra
> effort. fpGUI will automatically do translations between various
> popular formats.

This is a matter of extensions as well. Nice to have, but IMO subject to 
according libraries. Windows leaves it to the clipboard owner, to 
provide its data in any supported format, and only when requested by a 
clipboard viewer. Only very basic conversions (text encoding) are 
supplied by the OS, or may be supplied by e.g. fpGUI. Further filters or 
converters can be taken from e.g. syntax highlighters or other 
components, which can register themselves (see above).


>> Question remains: which mime type should be associated with e.g. dragging
>> files, or forms?
> 
> If it's between your own applications, you can use whatever mime-type
> makes sense to you. But between applications, the most common mine
> type would be 'text/uri-list'. URI lists are even good enough for DND
> between computers (Gnome took shortcuts here and doesn't support
> this). An example of the latter, is executing a X11 app or a remote
> server, while the display of that app is on your system. So dragging
> from that remote app to your local apps, the URI should contain the
> system name (or IP) too.

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.


>> How comes that I cannot drop anything from outside the demo app
> 
> I can drag text from a web page displayed in Firefox (data type is
> 'text/html' and a few others). I can also drag the URL of the website
> to the demo app, without problems.

Okay, Firefox works - but why then do you not simply show the CF_TEXT or 
CF_UNICODETEXT format?

Now that I have a source application, I can play a bit with the missing 
display features of the demo app...


>> , and no other app accepts the "Drag Me!"?
> 
> The demo registers 'text/plain' and 'text/html' mime-types, so only
> apps that accept that (or under Windows, the CF_TEXT format too) will
> receive data. I can drag the "Drag Me!" green label for example into
> gEdit and indeed I see the text data "My name is Earl" appear in
> gEdit. What system are you using to run that demo?

I'm using Win7, and none of the standard applications (notepad...) seems 
to even take notice of an drag from the demo app, while it reacts and 
accepts drops from other sources.

DoDi





More information about the Lazarus mailing list