Mac OS X - 如何监视窗口更改事件? [英] Mac OS X - How to monitor a window change event?

查看:436
本文介绍了Mac OS X - 如何监视窗口更改事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Cocoa应用程序,显示打开的窗口列表,并突出显示当前焦点。我的问题是,我找不到系统通知,以通知我的应用程序,主(aka专注或前台)窗口已更改。我试过:

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];

但它监视APPLICATION更改:执行窗口更改时不会触发。相同的应用程序(例如,如果我在使用exposè的两个Firefox窗口之间传递)。是否有系统范围的事件,我可以监视以跟踪主窗口的更改?

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?

提前感谢!

推荐答案

你最接近的可能是可访问性API。请参阅此处此处 a>对于(部分)解决方案的类似问题。

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

这篇关于Mac OS X - 如何监视窗口更改事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆