Jump to content
softtouch

Delphi 11 and onClose on macOS is still not called

Recommended Posts

When I close a form on macOS by clicking the top/left red close button of the form, the onClose event of the form is not trigggered. This was already with Delphi 10.4.x the same.

I need to save things and cleanup things when the form close, but how without the onClose event getting triggered?

Share this post


Link to post
11 minutes ago, softtouch said:

When I close a form on macOS by clicking the top/left red close button of the form, the onClose event of the form is not trigggered

Works for me in Delphi 11.3.

 

EDIT: That's when the form is not opened modally - I do note that there are these issues outstanding related to modal forms: 

https://quality.embarcadero.com/browse/RSP-39547
https://quality.embarcadero.com/browse/RSP-40158

So you may need to be more specific about how you are showing the form(s)
 

Edited by Dave Nottage

Share this post


Link to post
1 minute ago, Dave Nottage said:

Works for me in Delphi 11.3

It will only work when the form is the main form. When you open a form, and create there another form via buttonclick, that new form does not trigger its onClose event.

 

Example:

A main form is displayed and has a button. On the buttonclick, it created another form. That form, when its red close button is clicked, does not trigger its onClose event.

procedure TForm1.Button1Click(Sender: TObject);
begin
	myform:=TMyForm.Create(self);
	myform.ShowModal;
  	myform.Free;
end;

 

Share this post


Link to post
10 minutes ago, softtouch said:

It will only work when the form is the main form

It works when the form is not shown modally

10 minutes ago, softtouch said:

myform.ShowModal;

Please see the edits in my first reply.

Share this post


Link to post

The form is displayed with showmodal, not triggering onCloseQuery and onClose. onDestroy is triggeed, so I might move the code in onClose to onDestroy instead until this very old bug is fixed.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×