Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When clicking on an app icon in the dock after it's opened, what event can I receive?

Tags:

macos

swift

I am building an OS X app in Swift:

(1) Run the app

(2) The app starts and the app icon appears in the dock.

(3) Clicking on the app icon in the dock <-- How can my app get notification for this action?

I hope to do something after the user click the app icon in the dock when the app is running. How to get notified for this action?

like image 711
Joe Huang Avatar asked May 10 '17 05:05

Joe Huang


1 Answers

Implement

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool)

In your AppDelegate and make your application visible there.

See the documentation on more implementation details

like image 154
eli-bd Avatar answered Sep 20 '22 12:09

eli-bd