[Lazarus] Generalized DragDrop

Graeme Geldenhuys graemeg.lists at gmail.com
Sun Jan 23 11:05:40 CET 2011


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). 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).


> 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.

> 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.


> 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.


> 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.


> , 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?


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net




More information about the Lazarus mailing list