Thank you Zeljko for chiming in!
Apologies, this was a left-over from testing all kinds of combinations.
Unfortunately, just using
ModalResult:=mrOK doesn't work either - that's what I started with (see code below).
Calling Close (instead of setting ModalResult) didn't work either, so that's when I started trying all kinds of weird things to see what will work.
p.s. The FormClose event does not seem to get fired fired either, until user moves the mouse.
So the code below results in exact the same issue.
It's almost like the mouse needs to be moved to get the message that the window needs to be closed to be processed.
(I have hardly any experience with the entire messaging in the background - so my apologies if I'm describing this wrong)
Note:
- Everything I tried works under Linux and Windows. Just not under Cocoa.
- I forgot to mention that I've tested this with several Lazarus/FPC versions, Intel and AARCH, and Monterey and Ventura.
Last version I tried is: Lazarus 2.3.0 (rev main-2_3-2069-g4aa7b5b350) FPC 3.2.2 x86_64-darwin-cocoa
unit Unit2;
{$mode ObjFPC}{$H+}
interface
uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls;
type
{ TForm2 }
TForm2 = class(TForm)
Timer1: TTimer;
procedure FormShow(Sender: TObject);
procedure Timer1StartTimer(Sender: TObject);
procedure Timer1StopTimer(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
Counter:integer;
public
end;
var
Form2: TForm2;
implementation
{$R *.lfm}
{ TForm2 }
procedure TForm2.FormShow(Sender: TObject);
begin
Timer1.Enabled:=true;
end;
procedure TForm2.Timer1StartTimer(Sender: TObject);
begin
Counter := 0;
self.caption := 'Timer start';
end;
procedure TForm2.Timer1Timer(Sender: TObject);
begin
inc(Counter);
self.caption := 'Timer '+IntToStr(Counter);
if Counter>5 then Timer1.Enabled:=false;
end;
procedure TForm2.Timer1StopTimer(Sender: TObject);
begin
self.caption := 'Timer done';
ModalResult:=mrOK;
end;
end.