gpt4 book ai didi

macos - Mac OS X/Cocoa : create "docked" sidebar that reduces maximizable area, 就像 Dock

转载 作者:行者123 更新时间:2023-12-03 16:21:37 27 4
gpt4 key购买 nike

当 OS X 扩展坞显示时,它会“保留”一些屏幕区域,并防止最大化的窗口在最大化时移至扩展坞后面。如何让我自己的 Cocoa 应用程序执行相同的操作?

最佳答案

窗口的“最大化区域”基于屏幕的visibleFrame

[[NSScreen mainScreen]visibleFrame]

The returned rectangle is always based on the current user-interface settings and does not include the area currently occupied by the dock and menu bar.

Because it is based on the current user -interface settings, the returned rectangle can change between calls and should not be cached. The rectangle defining the portion of the screen in which it is currently safe to draw your application content.

没有提到能够调整此 visibleFrame 矩形,因此我认为您不会成功影响“全局”缩放大小。

但是,如果您只想调整应用窗口的缩放大小,请在 NSWindowDelegate 方法中返回一个较小的矩形windowWillUseStandardFrame:defaultFrame:.

The standard frame for a window should supply the size and location that are “best” for the type of information shown in the window, taking into account the available display or displays. For example, the best width for a window that displays a word-processing document is the width of a page or the width of the display, whichever is smaller. The best height can be determined similarly. On return from this method, the zoom: method modifies the returned standard frame, if necessary, to fit on the current screen.

这将允许您在缩放应用窗口时考虑“停靠侧边栏”。您的应用程序的窗口。其他应用程序将在停靠的侧边栏顶部调整大小。

关于macos - Mac OS X/Cocoa : create "docked" sidebar that reduces maximizable area, 就像 Dock,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8408812/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com