Recent

Author Topic: [Solved] Why TForm.OnDropFiles is not called on double-click in Finder?  (Read 344 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 1998
    • UVviewsoft
I have a regression in CudaText editor: double-click in Finder, or 'Open with' in Finder - they don't call TFormMain.OnDropFiles with the clicked file. So editor cannot open associated document!

OnDropFiles _is_ still called OK when I drag-drop the document from Finder.
OnDropFiles _is_ still called OK in empty form demo. (So not a Lazarus regression.)
TForm.AllowDropFiles is on.

I cannot get the idea, what I broke.
.plist file is still the same (3 years).
macOS-specific code was not added to app in last years.
Any ideas?

macOS 10.8 and 11.x. Lazarus 2.2 release and 2.3 trunk.
« Last Edit: December 12, 2022, 11:15:46 pm by AlexTP »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2004
  • Former Delphi 1-7, 10.2 user
Re: Why TForm.OnDropFiles is not called on double-click in Finder?
« Reply #1 on: November 20, 2022, 02:37:23 pm »
Perhaps this paragraph from my Wiki article on macOS File and Custom URL Scheme Associations relates to your issue?
Lazarus 2.3, FPC 3.3.1 macOS 12.6.1 x86_64 Xcode 14.1
Lazarus 2.3, FPC 3.3.1 macOS 12.6.1 aarch64 Xcode 14.1

AlexTP

  • Hero Member
  • *****
  • Posts: 1998
    • UVviewsoft
Re: Why TForm.OnDropFiles is not called on double-click in Finder?
« Reply #2 on: November 20, 2022, 02:48:37 pm »
This wiki text tells
>It should be noted that the legacy keys are still working in macOS 10.15.4 (Catalina).

So my old Info.plist file must be OK for macOS 10.11 and 10.8. So, it is not the reason.

AlexTP

  • Hero Member
  • *****
  • Posts: 1998
    • UVviewsoft
Re: [Solved] Why TForm.OnDropFiles is not called on double-click in Finder?
« Reply #3 on: December 12, 2022, 11:17:53 pm »
Solved. Reason is this: TForm.OnDropFiles indeed was not called because TApplication.MainForm=Nil at the time of Cocoa handler work! but TApplicationProperties.OnDropFiles was! COCOA code shows that it first tries to call TApplicationProperties.OnDropFiles.
I added this reaction and solved the bug.

 

TinyPortal © 2005-2018