Recent

Author Topic: [Solved] Bug with Cocoa application-delegate class?  (Read 1841 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2479
    • UVviewsoft
[Solved] Bug with Cocoa application-delegate class?
« on: September 15, 2022, 05:37:19 pm »
MacOS 10.8 and 11.x.
I see a regression in CudaText,--  app don't get TForm.OnDropFiles when I run the editor from Finder (dbl click on text file or do 'open with'). App runs but don't get OnDropFiles.
I added the Application.MessageBox here:

lazarus/lcl/interfaces/cocoa/cocoaobject.inc
Code: Pascal  [Select][+][-]
  1. procedure TAppDelegate.application_openFiles(sender: NSApplication; filenames: NSArray);
  2. var
  3.   lFiles: array of string;
  4.   lNSStr: NSString;
  5.   i: Integer;
  6. begin
  7.   SetLength(lFiles, filenames.count);
  8.   for i := 0 to filenames.count-1 do
  9.   begin
  10.     lNSStr := NSString(filenames.objectAtIndex(i));
  11.     lFiles[i] := NSStringToString(lNSStr);
  12.   end;
  13.   Application.MessageBox('App openFiles, cnt: '+IntTOstr(filenames.count), 'Cocoa'); //debug
  14.   Application.IntfDropFiles(lFiles);
  15.   if Application.MainForm<>nil then
  16.     Application.MainForm.IntfDropFiles(lFiles);
  17. end;
  18.  

and msgbox is not called! Maybe a regression in FPC?
This procedure is in the cocoa/cocoaint.pas:

Code: Pascal  [Select][+][-]
  1.   TAppDelegate = objcclass(NSObject, NSApplicationDelegateProtocol)
  2.   public
  3.     orderArray : PWinLevelOrderArray;
  4.     orderArrayCount : Integer;
  5.     procedure application_openFiles(sender: NSApplication; filenames: NSArray);
  6.  

I do cross compile from Linux x64 to Mac.
user@PC:~/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux$ ./fpc
Free Pascal Compiler version 3.2.3-660-g9b2ba834a6 [2022/08/18] for x86_64
It is 'fixes' branch.
« Last Edit: September 15, 2022, 08:16:39 pm by AlexTP »

AlexTP

  • Hero Member
  • *****
  • Posts: 2479
    • UVviewsoft
Re: Maybe a bug with Lazarus Cocoa application-delegate class
« Reply #1 on: September 15, 2022, 07:57:51 pm »
Sorry, problem seems not in FPC, 3.2 release shows the same.

 

TinyPortal © 2005-2018