Drop files event: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | The drop files event will be invoked when the user drops one or multiple dragged files on one of application's forms. | |
| 2 | 2 | ||
| 3 | 3 | First this event should be fired for target form (or main form if drop target is unknown), then for the application. | |
| 4 | 4 | ||
| 5 | 5 | ## Possible implementation for LCL | |
| 6 | 6 | ||
| 7 | - | ||
| 7 | + | ``` pascal | |
| 8 | + | TDropFilesEvent = procedure (Sender: TObject; const FileNames: Array of String) of Object; | |
| 9 | + | ``` | |
| 8 | 10 | ||
| 9 | 11 | Add OnDropFiles: TDropFilesEvent to TCustomForm, TApplication and TApplicationProperties. Each form will have property AllowDropFiles: Boolean, which enables this event. | |
| 10 | 12 | ||
| 11 | 13 | ## Possible implementation per widgetsets | |
| 12 | 14 | ||
| 13 | 15 | The widgetsets should call method IntfDropFiles of target form (or main form if drop target is unknown) and the application. | |
| 14 | 16 | ||
| 15 | 17 | ### Win32/64 | |
| 16 | 18 | ||
| 17 | 19 | - set DragAcceptFiles for every form | |
| 18 | 20 | - respond to WM_DROPFILES message | |
| 19 | 21 | ||
| 20 | 22 | ### GTK1/2 | |
| 21 | 23 | ||
| 22 | 24 | - enable: gtk_drag_dest_set | |
| 23 | 25 | - respond to drag_data_received signal | |
| 24 | 26 | ||
| 25 | 27 | ### Qt | |
| 26 | 28 | ||
| 27 | 29 | - enable widget by setAcceptDrops(true) | |
| 28 | 30 | - respond to dragEnterEvent by event-\>acceptProposedAction for mime-type text/uri-list | |
| 29 | 31 | - respond to dropEvent | |
| 30 | 32 | - docs: [1](http://doc.trolltech.com/4.2/dnd.html#dropping) | |
| 31 | 33 | ||
| 32 | 34 | ### Carbon | |
| 33 | 35 | ||
| 34 | 36 | - respond to kAECoreSuite/kAEOpenDocuments event to open application associated files | |
| 35 | 37 | - modify Application Bundle | |
| 36 | 38 | ||
| 37 | 39 | ## Related bug reports | |
| 38 | 40 | ||
| 39 | 41 | - [bug 1772](http://www.freepascal.org/mantis/view.php?id=1772) | |
| 40 | 42 | - [bug 8976](http://www.freepascal.org/mantis/view.php?id=8976) | |
| 41 | 43 | ||
| 42 | 44 | ## TODO | |
| 43 | 45 | ||
| 44 | 46 | 1. implement for Qt already implemented (during 0.9.27) | |
| 45 | 47 | ||
| 46 | 48 | --- | |
| 47 | 49 | *From the Free Pascal wiki, page "Drop files event", as it stood on 2017-04-05 after a change by Bart, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 48 | 50 | Category: Event-driven programming |
