softtouch 9 Posted October 23, 2023 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
Dave Nottage 557 Posted October 23, 2023 (edited) 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 October 23, 2023 by Dave Nottage Share this post Link to post
softtouch 9 Posted October 23, 2023 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
Dave Nottage 557 Posted October 23, 2023 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
softtouch 9 Posted October 23, 2023 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