NSApp hide: 实际上对 NSWindow 实例做了什么?

发布于 2024-09-28 23:24:56 字数 672 浏览 6 评论 0原文

我正在开发一个 NSWindow 子类,并且遇到了一些奇怪的行为,这让我对 Windows 在 Mac OS X 上如何工作的一些假设产生了疑问。

NSWindow< 到底发生了什么调用 [[NSApplication sharedApplication] hide: self] 时的 /code> 实例?

所有不向 -(BOOL)canHide 返回 NO 的窗口都会从屏幕上消失。然后,当应用程序变为活动状态或调用 [NSApplication sharedApplication] unhide: self] 时,所有窗口都会重新出现。

我假设这可以通过拍摄当前窗口状态的快照,然后在所有 NSWindow 实例上调用 orderOut: ,然后在 时向后执行整个过程来实现。 >unhide: 被调用。

然而,情况似乎并非如此。我的 NSWindow 子类的 orderOut: 方法没有被调用..事实上它也没有隐藏。它确实将 setCanHide: 设置为 YES,但发生了什么?

任何见解将非常感激。

最好的问候,

弗兰克

I'm working on an NSWindow subclass and I'm running into some strange behavior that makes me question some of my assumptions about how windows work on Mac OS X.

What precisely happens to NSWindow instances when [[NSApplication sharedApplication] hide: self] is called?

All windows that do not return NO to -(BOOL)canHide disappear from the screen. Then all windows re-appear when the application becomes active or [NSApplication sharedApplication] unhide: self] is called.

I had assumed that this would be achieved by taking a snapshot of the current window state, then calling orderOut: on all NSWindow instances and then performing the whole thing backwards when unhide: is called.

That does not seem to be the case, however. The orderOut: method of my NSWindow subclass isn't called.. in fact it's not hidden either. It does set setCanHide: to YES though.. what's happening?

Any insights would be very much appreciated.

Best regards,

Frank

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奢欲 2024-10-05 23:24:56

启动 Instruments 并亲自找出答案!在我的机器 (10.6.4) 和 32 位应用程序上,[NSApplication hide:] 调用 ShowHideProcess。它在那里记录:

http://developer.apple。 com/library/mac/#documentation/Carbon/Reference/Process_Manager/process_mgr_ref.pdf

然后,ShowHideProcess 调用 CPSPostHideReqCoreGraphics 中的某些内容) em>)。

但没有 orderOut:,实际上根本没有 objc_msgSend() 。

你需要它做什么?或者你只是好奇?因为在大多数情况下,您应该很好地监听 NSApplicationWill/DidHideNotification

Fire up Instruments and find out for yourself! On my machine (10.6.4) and a 32-Bit application, [NSApplication hide:] calls ShowHideProcess. It's documented there:

http://developer.apple.com/library/mac/#documentation/Carbon/Reference/Process_Manager/process_mgr_ref.pdf

The ShowHideProcess then calls CPSPostHideReq (something in CoreGraphics).

But there is no orderOut:, actually no objc_msgSend() at all.

What do you need it for? Or were you just curious? Because for most cases, you should do just fine listening for the NSApplicationWill/DidHideNotification.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文