Mac Desktop app in Dock: a question

Until now, just been using Xojo to develop a Web app. Now I’m working on a Desktop app on the Mac. I notice that when the built app’s last window is closed, its icon still appears in the System Tray as expected. But when I click on that System Tray icon, its window fails to appear. I’m used to Mac apps reappearing when click on their icon after having closed their window previously.

When I think about it, it seems that Mac apps essentially get minimized when their window is closed (unlike Windows apps, which Quit when their window is closed). Is that what I have to code to make this app work like that?

For now, it seems that the most unconfusing way to handle this is to put AutoQuit=True in the App.Open event. That way the user isn’t confused by the existence of the System Tray icon that fails to bring back the window the recently closed.

Calling the Dock “System Tray” is not a good idea.

And no, Mac apps don’t get minimized when their windows are closed. You can make apps “sticky” in the Dock by selecting “Stay in Dock” from the options menu. This doesn’t happen automatically. When doing Skype sessions with customers I have seen screens with dozens of apps in the Dock.

Then there is the whole mess of app nap when the OS decides on it’s own when to quit the app or not. You can disable this.

MacOS can restore open documents after restarting. I’m not sure if Xojo can do this.

Some apps do AutoQuit. Most don’t.

I would recommend getting a bit more experience on Macs/MacOS.

Yes. I was confused describing what I’m used to seeing on the Mac. Let’s take Chrome. On the Mac, when I close Chrome, it remains running without an open window. When I click on its icon in the Dock (sorry for calling it System Tray), it loads a window again.

And when I create a Xojo Desktop app, and run it, and close its single window, it keeps running and remains in the Dock, just like Chrome. But when I then click on its Dock icon, no window appears. Is there a way to code this app so that clicking on its Dock icon while still running, loads its window?

You could try to use App.activate to show a new window if none is visible. Like Xojo does with the launcher window.

App.newdocument is what you’re looking for.

On the Mac, closing a window doesn’t automatically quit the app(lication).

Probably like written above. Even the Finder Dock icon opens a new window if it has been clicked.

When you have an application icon on the Dock, what happens when you press the Command-Tab keys ?

Yep. That does it. Thanks, Sam.

App.NewDocument (event)
Window1.Show

The window is not revived, though the app becomes active again. The App.NewDocument event solved this for me.

You closed it. So, you have to open it gain.