Recent

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

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
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.
« Last Edit: September 13, 2015, 07:54:00 am by Hansaplast »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #1 on: January 09, 2011, 09:39:23 pm »
No. OnDropFiles should get fired at any place you drop the file.

At least it is so on Windows.
« Last Edit: January 09, 2011, 09:44:34 pm by typo »

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #2 on: January 10, 2011, 12:07:54 am »
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 ...!?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #3 on: January 10, 2011, 12:12:57 am »
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

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #4 on: January 10, 2011, 12:15:29 am »
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 ...
« Last Edit: January 10, 2011, 12:23:06 am by Hansaplast »

rajivsoft

  • New Member
  • *
  • Posts: 48
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #5 on: February 03, 2011, 11:05:57 am »
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...

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #6 on: February 03, 2011, 09:14:01 pm »
Thanks for confirming :)

I posted a bug for this. (link to bug 18486)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #7 on: February 28, 2011, 12:43:36 am »
Thanks for posting the bug, this is not working for me either.
“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)

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #8 on: March 04, 2011, 09:10:29 pm »
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.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

Dr.Theopolis

  • Jr. Member
  • **
  • Posts: 69
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #9 on: May 09, 2012, 07:41:46 am »
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.

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #10 on: June 03, 2012, 01:11:35 pm »
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.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

leosok

  • New member
  • *
  • Posts: 9
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #11 on: June 13, 2012, 06:06:26 am »
It still does not work.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #12 on: June 13, 2012, 07:45:13 am »
Try the bugtracker.

Shebuka

  • Sr. Member
  • ****
  • Posts: 427
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #13 on: June 13, 2012, 09:59:40 am »
Try the bugtracker.
It is on bugtracker, or you mean that one must first check on bugtracker if the issue was resolved?  8)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: OnDropFiles - Only works with dock icon, not with Application Form
« Reply #14 on: June 13, 2012, 11:09:58 am »
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.
« Last Edit: June 13, 2012, 11:47:26 am by typo »

 

TinyPortal © 2005-2018