Firemonkey MacOS app – Close vs Quit

  

I have developed a MacOS application using Firemonkey XE8 and I have noticed that the X button of the main form actually terminates the application instead of hiding/minimizing it as it is the default behavior in most of the MacOS apps.

To solve this issue I have added the following logic in the FormCloseQuery to minimize the app if someone click the X button:

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin

{$IFDEF MACOS}
if (Self.WindowState<>TWindowState.wsMinimized) then begin
Self.WindowState:=TWindowState.wsMinimized;
CanClose:=false;
end
else
CanClose:=true;
{$ENDIF MACOS}

end;

This works but the side effect is that if someone right click the application in the Dock and select Quit, the application will be minimized if the form is not already minimized. So the user should click Quit two times to really close the app.

Is there any way to fix this? The close button should hide/minimize the window and the Quit should terminate the application.

Comments are closed.