如何检查 NSWindow 是否可见
有没有办法检查 NSWindow 是否可见?我想在我的应用程序的第一个窗口可见时显示一个工作表控制器(10.7 上的动画结束,用户可以看到该窗口!)。如果我只是在 windowDidLoad 中显示工作表,则会产生看起来很愚蠢的动画(工作表滚动出来,窗口从后面弹出)。我知道 NSWindowDelegate 提供了两种方法,当窗口成为关键窗口或主窗口时会调用这两种方法,但是,这并不一定意味着该窗口当时已经完全可见。这在 Lion 上更为明显,因为窗口往往会弹出这种愚蠢的动画。
Is there a way to check if a NSWindow
is visible or not? I want to display a sheet controller once the first window of my app became visible (the animation on 10.7 ended and the user can see the window!). If I just show the sheet in windowDidLoad
, it results in a stupid looking animation (sheet rolling out, window popping out from the back). I know that NSWindowDelegate
provides two methods which are invoked when a window either became the key window or the main window, however, this doesn't have to mean that the window is already fully visible at the time. This is even more noticeable on Lion where windows tend to pop up with this stupid animation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会选择这样的东西:
或者是这个关键路径的观察者,当变化发生时会收到通知。
I would go for something like this:
Or an an observer for this key path to be notified when the change occurs.
对于它的价值,您还可以绑定到 window.visible 属性。 Xcode 4 可能会警告你,说它不是可绑定的属性,但它会起作用。
如果您尝试根据窗口是否可见以及其他方法来启用/禁用显示/隐藏 NSStatusItem,这可能会很有用。
即在 Interface Builder 中:
For what it's worth, you can also bind to the window.visible property. Xcode 4 may squawk at you, saying it's not a bindable property, but it will work.
This can be useful if you are trying enable/disable show/hide NSStatusItem based on whether the window is visible, as well as other approaches.
i.e. in Interface Builder: