Mac OS X - How to track a window change event?

I am developing a Cocoa application that displays a list of open windows and highlights the current focus. My problem is that I cannot find a system notification to inform my application that the main (aka "focused" or "front") window has changed. I tried:

[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(wsNotificationHook:) name:NSWorkspaceDidActivateApplicationNotification object:nil]; 

but it tracks the APPLICATION change: it does not start when the INSIDE window of the same application is modified (for example, if I pass between two Firefox windows using exposรจ). Is there a system event that I can track to track the change in the main window?

Thank you in advance!

+4
source share
1 answer

The closest you get is probably the accessibility APIs. See here and here for similar questions with (partial) solutions.

+2
source

Source: https://habr.com/ru/post/1369328/


All Articles