NSAppleEventManager.shared().setEventHandler steal the focus

430 views Asked by At

When register for url activation in my app with

NSAppleEventManager.shared().setEventHandler(self, andSelector: #selector(self.handleEvent(_:with:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))

I'm getting the callback in my app when my app is stealing the focus of the user in the Mac, at the end of the activation of my func 'handleEvent()'.

I don't want my app to steal the focus since I'm running in the background, and the user doesn't even know why his current app lost her focus.

How can I set it to keep running without stealing the user's focus ?

1

There are 1 answers

0
Yaron Abramovich On BEST ANSWER

Since I got no answer, I switched the methodology and used DistributedNotificationCenter to communicate between 2 apps.

No focus stealing with this solution.