Lazarus
Programming => Widgetset => Carbon => Topic started by: Hansaplast on January 09, 2011, 09:35:32 pm
-
When enabling "AllowdropFiles" on the mainform, the OnDropFiles event only gets fired when I drop something on the dock icon. Dropping files on the form doesn't do anything.
Is this by design? Or am I overlooking something?
OS: 10.6.6, Mac Intel (i386-darwin-carbon)
XCode: 3.2.5
Lazarus nightly build: 0.9.31 (2011-01-08)
FPC: 2.4.2 (SVN 28900)
Update: Just tested this in 1.4.2 and now it works as expected.
-
No. OnDropFiles should get fired at any place you drop the file.
At least it is so on Windows.
-
That's what I was hoping for ... hmm
Mainform (and only form) AllowDropFiles = TRUE,
under Events "OnDropFiles" -> procedure that shows a simple "hello" message.
Drag file from Finder window to the mainform (after first making sure that the mainform is the frontmost and active application); nothing happens, the onDropFiles event does not get fired.
I tried to drop the file(s) in different locations; on components, on areas where there are no components, on the titlebar ,... nothing happens.
Dropping the file(s) on the dock icon of the application: onDropFiles get fired ...!?
-
Right, that doesn't work here either.
I seem to recall this question asked before. You might to search the forum.
And file a bug report if you can't find a solution.
Thanks.
-Phil
-
Does anyone know how to search the bugtracker to see if this is an existing issue? :'(
I did find two related posts (from 2008), but no answers there either ...
-
When enabling "AllowdropFiles" on the mainform, the OnDropFiles event only gets fired when I drop something on the dock icon. Dropping files on the form doesn't do anything.
Is this by design? Or am I overlooking something?
OS: 10.6.6, Mac Intel (i386-darwin-carbon)
XCode: 3.2.5
Lazarus nightly build: 0.9.31 (2011-01-08)
FPC: 2.4.2 (SVN 28900)
Also I'v tried to use AllowDropFiles, and the example application, with onDropFile and simple message and only drop on dock icon fires onDropFile event...
-
Thanks for confirming :)
I posted a bug for this. (link to bug 18486 (http://bugs.freepascal.org/view.php?id=18486))
-
Thanks for posting the bug, this is not working for me either.
-
Did you read the topic http://www.lazarus.freepascal.org/index.php/topic,12231.0.html ?
It may be of limited help at present, but the link may be useful, anyway.
-
Is there any new information about this? As of Lazarus 0.9.30.4 and fpc 2.6.0 w carbon widgetset, this problem is still there.
In researching it, it looks like apps have to call an api function (registerForDraggedTypes) to register the types of files they can accept, otherwise the OS will not even send the appropriate messages to the app when files are dropped.
Then, when files are dropped on the app certain messages need to be responded to, and when I looked at the source code in the place where it deals with kAEOpenDocument, I did not see any mention of the other messages that need to be responded to.
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.
If anyone has any new info on getting onDropFiles to fire when dropping files onto the running app itself (not just the dock icon), please let me know.
-
Unfortunately, many bugs that are called to be "resolved" in the bug tracker are in fact not fixed in the latest Lazarus versions for Mac.
See
http://bugs.freepascal.org/view.php?id=20298
http://bugs.freepascal.org/view.php?id=20331
http://bugs.freepascal.org/view.php?id=20425
to mention just a view examples of many.
-
It still does not work.
-
Try the bugtracker.
-
Try the bugtracker.
It is on bugtracker, or you mean that one must first check on bugtracker if the issue was resolved? 8)
-
Often they come here first. So, if it is not resolved, go to the bugtracker.
This thread has been resurrected and something may have changed in the interim. Some newbies do not feel comfortable to create a new thread.
Noting that the thread is old, he could go directly to the bugtracker, probably searching for some related bug or eventually reporting it.
The bug is here ( http://bugs.freepascal.org/view.php?id=18486 ), marked as acknowledged. Maybe he can add some note.
-
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;
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;
-
...
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 (http://www.lazarus.freepascal.org/index.php/topic,17536.0.html)) for different purposes.
As far as I know the NSView is Apple specific and indicates a drawable area ...!?
-
Did you make any progress with insight into the NSView object?
I'm rather confused about NSView as well (see my VLC post (http://www.lazarus.freepascal.org/index.php/topic,17536.0.html)) 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
-
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 ,.. :(
-
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.
-
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
-
It is not fixed in Lazarus 1.0.14, maybe the next release.