Recent

Author Topic: [SOLVED] OnDropFiles - Only works with dock icon, not with Application Form  (Read 30799 times)

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #15 on: July 24, 2012, 04:55:41 am »
I guess keeping a thread alive isn't necessarily a bad thing.
Newbies, including myself, will have an indication that this is still an open issue.
Specially when not comfortable of familiar with the Bugtracker.

ps. Application.AddOnDropFilesHandler shows exactly the same issue - which makes me think that it is actually the only thing that works and allows dropping files on Applications. Adding a handler to the TApplication only picks up files dropped on the dock icon :(

So the code below doesn't work either;

Code: [Select]
procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.AddOnDropFilesHandler(@OnApplicationDropFiles);
end;

...

procedure TForm1.OnApplicationDropFiles(Sender: TObject; const FileNames: array of String);
begin
  ShowMessage('Files dropped');
end;

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #16 on: July 31, 2012, 08:03:02 pm »
...
registerForDraggedTypes is a procedure of the NSview class. I'm trying to figure out what that is exactly, but it seems like it is just a rectangle representing a visible area. I'm trying to figure out if I can create an NSview object for my main form window and then call registerForDraggedTypes. But this is my first time at doing any programming on Mac so I really don't know what I'm doing.
...

Did you make any progress with insight into the NSView object?
I'm rather confused about NSView as well (see my VLC post) for different purposes.
As far as I know the NSView is Apple specific and indicates a drawable area ...!?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #17 on: August 01, 2012, 04:40:02 am »

Did you make any progress with insight into the NSView object?
I'm rather confused about NSView as well (see my VLC post) for different purposes.
As far as I know the NSView is Apple specific and indicates a drawable area ...!?

NSView is an Objective-C class in Cocoa's AppKit framework. It doesn't make sense to talk about it if you're using the Carbon widgetset.

To use with Cocoa, here's docs and example:

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html#//apple_ref/doc/uid/TP40004149

http://juliuspaintings.co.uk/cgi-bin/paint_css/animatedPaint/072-NSView-drag-and-drop.pl

Thanks.

-Phil

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #18 on: August 02, 2012, 05:20:32 am »
As usual; Phil helps out :)
Thanks Phil.

Well, I was already afraid of that - poking around, reading etc ... couldn't find how to get this to work in Carbon :(
I guess some low level work is needed to get even close.

The alternative would be a "drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding", which sounds equally difficult ,.. :(

Dr.Theopolis

  • Jr. Member
  • **
  • Posts: 69
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #19 on: January 11, 2013, 11:48:38 pm »
I think I've made a good start at fixing the problem. The fix involves code utilizing the Drag Manager (see https://developer.apple.com/legacy/mac/library/#documentation/Carbon/Reference/Drag_Manager/Reference/reference.html).

I have updated the bugtracker issue# 18486 and uploaded a file. It needs more work I'm sure, but at least onDropFiles fires when dragging files to the application.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #20 on: November 11, 2013, 03:57:56 pm »
That seems to have fixed it! I just tried the "dropfiles" example and it works properly. I hope your fix can be incorporated into the next release.

Many thanks Dr.Theopolis.

Cheers,
Frederick
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #21 on: December 03, 2013, 12:39:36 am »
It is not fixed in Lazarus 1.0.14, maybe the next release.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

 

TinyPortal © 2005-2018