I'm developing software that implements functionality for third party touch screens. It provides features such as having touch gestures trigger mouse clicks and drags, among other possible actions.
One of its features allows keyboard focus to return to whichever app originally had it prior to performing a touch gesture. Previously it worked by recording the current frontmost app when a touch action starts, and then when all touch actions have concluded, calling NSRunningApplication.activateWithOptions
and passing NSApplicationActivateIgnoringOtherApps
.
However, in macOS 14 and later, this no longer works, as NSRunningApplication.activateWithOptions
is deprecated. The new API provides a way for the current frontmost app to yield frontmost to whichever app is being activated with the new functions NSRunningApplication.yieldActivationToApplication
and NSRunningApplication.activate
, but in my case it just silently fails, presumably because my app in that moment is not frontmost. (However there is no error code provided for me to be able to find out what exactly the issue is.)
Is there a supported way I can fix this feature in macOS 14 and later?