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

Deadly 提交于 2019-12-21 17:06:03

问题


I'm developing a Cocoa application that shows a list of opened windows and highlights the current focused one. My problem is that I can't find a system notification to inform my app that the main (aka "focused" or "foreground") window has changed. I tried with:

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

but it monitors APPLICATION change: it isn't get fired when a change of window is executed INSIDE the same application (for example, if I pass between two Firefox windows using exposè). Is there a system-wide event that I can monitor to track a change of the main window?

Thank you in advance!


回答1:


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



来源:https://stackoverflow.com/questions/7217724/mac-os-x-how-to-monitor-a-window-change-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!