开发者

Can I monitor other windows' event like resizing, hiding etc from NSNotificationCenter?

I'd like to monitor all windows (include other applications' windows) changes like resizing, hiding, un-hiding etc. I found that if I use

[NotificationCenter defaultCenter]

, I just开发者_StackOverflow receive the event from my own application's window. But how about

NSWorkspace's notification center?


NSWorkspace doesn't have anything to do with windows, so no.

The distributed notification center won't work, either.

Keep in mind that a notification center is not merely a portal by which to observe things; things have to post notifications on it. An NSWindow object does that when the user resizes its window, but it does it only on the default local notification center, not the distributed one nor NSWorkspace's. Therefore, that's the only notification center on which you can observe for window notifications and get anything for it, and you'll only get them about your own windows.

You can use the Accessibility API to observe a property of a window in any process, but notifications won't come in during a drag, only after it, and the user will need to have “Access for assistive devices” turned on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜