Mac Window Mac 窗口 macos
The movable Mac app frame, from its title bar and toolbar to its resize edges
可移动的 Mac 应用框架,从标题栏、工具栏一直到调整大小的边缘
标本可交互 —— 点点看。Specimen is live — try it.
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Title bar标题栏
NSWindow.titleVisibility“The strip across the top of the window” is the title bar, which can remain present even when its title text is hidden.
「窗口顶部那条横条」就是标题栏,即使标题文字隐藏了,它也可以保留。
Prompt fragmentPrompt 片段the Mac window's title bar (NSWindow.titleVisibility): the top chrome containing the title, traffic lights, and optional unified toolbar
Mac 窗口的标题栏(NSWindow.titleVisibility):顶部外框,包含标题、红绿灯按钮和可选的统一工具栏
-
2 Window drag region窗口拖动区域
NSWindow.isMovableByWindowBackgroundThe blank area you grab to move the window is its drag region, not necessarily the visible title text.
按住就能移动窗口的空白区域是拖动区域,不一定是看得见的标题文字。
Prompt fragmentPrompt 片段the window drag region (NSWindow.isMovableByWindowBackground): an unobstructed title-bar area that moves the NSWindow when dragged
窗口拖动区域(NSWindow.isMovableByWindowBackground):标题栏内无遮挡的区域,拖动它会移动整个 NSWindow
-
3 Window title窗口标题
NSWindow.titleThe document or screen name printed in the title bar is the window title.
显示在标题栏里的文档名或界面名就是窗口标题。
Prompt fragmentPrompt 片段the window title (NSWindow.title): the document or screen name positioned in the title-bar chrome
窗口标题(NSWindow.title):放在标题栏外框里的文档名或界面名
-
4 Unified toolbar统一工具栏
NSWindow.ToolbarStyle.unifiedWhen the title and window actions share one top row, that chrome uses the unified toolbar style.
当标题和窗口操作按钮共用顶部同一行时,这个外框用的就是统一工具栏样式。
Prompt fragmentPrompt 片段a unified Mac toolbar (NSWindow.ToolbarStyle.unified) sharing the title bar's single row instead of sitting in a separate strip
一个统一的 Mac 工具栏(NSWindow.ToolbarStyle.unified):与标题栏共用一行,而不是单独占一条
-
5 Toolbar item工具栏项
NSToolbarItemOne button, field, or flexible space placed in the window toolbar is a toolbar item.
放在窗口工具栏里的一个按钮、输入框或弹性空隙,就是一个工具栏项。
Prompt fragmentPrompt 片段a native toolbar item (NSToolbarItem) placed with macOS toolbar spacing, validation, and overflow behavior
一个原生工具栏项(NSToolbarItem),遵循 macOS 工具栏的间距、校验和溢出行为
-
6 Title-bar accessory标题栏附加控件
NSTitlebarAccessoryViewController“The little control inside the title bar” is a title-bar accessory, separate from both the toolbar and traffic lights.
「标题栏里那个小控件」就是标题栏附加控件,和工具栏、红绿灯按钮都不相干。
Prompt fragmentPrompt 片段a title-bar accessory (NSTitlebarAccessoryViewController): a custom control strip attached to an edge of the NSWindow title bar, separate from NSToolbar
标题栏附加控件(NSTitlebarAccessoryViewController):附着在 NSWindow 标题栏某条边上的自定义控件条,独立于 NSToolbar
-
7 Title-bar separator标题栏分隔线
NSWindow.titlebarSeparatorStyleThe hairline between the window's top chrome and its content is the title-bar separator.
窗口顶部外框和内容之间那条细线就是标题栏分隔线。
Prompt fragmentPrompt 片段the title-bar separator (NSWindow.titlebarSeparatorStyle): the native hairline between the title-bar or toolbar chrome and window content
标题栏分隔线(NSWindow.titlebarSeparatorStyle):标题栏或工具栏外框与窗口内容之间的原生细线
-
8 Window tabs窗口标签页
NSWindowTabGroupTabs in the window frame group separate document windows; they are not an NSTabView inside the content area.
窗口框架里的标签页用来把独立的文档窗口编组,不是内容区里的 NSTabView。
Prompt fragmentPrompt 片段native window tabs (NSWindowTabGroup): a tab strip in the window frame that groups separate NSWindow documents, not an in-content NSTabView
原生窗口标签页(NSWindowTabGroup):窗口框架里的标签条,把多个独立的 NSWindow 文档编组,而不是内容里的 NSTabView
-
9 Resize edge / corner调整大小边缘/角落
NSWindow.StyleMask.resizable“The tiny corner grip” means the resize edge or corner, which may be interactive even when no grip is drawn.
「角落里的小抓手」指调整大小的边缘或角落,即使没画出抓手,它也可能是可交互的。
Prompt fragmentPrompt 片段the native resize edge and corner (NSWindow.StyleMask.resizable): the draggable window-frame boundary, including the bottom-right size-grip area
原生的调整大小边缘和角落(NSWindow.StyleMask.resizable):可拖动的窗口框架边界,包括右下角的大小抓手区域
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Build this as a native Mac Window (NSWindow; SwiftUI: Window or WindowGroup). Distinguish the draggable title-bar region from NSWindow.title, use an NSToolbar for unified chrome, attach custom title-bar controls with NSTitlebarAccessoryViewController, and preserve native window tabs and resize edges.
把它构建为原生 Mac 窗口(NSWindow;SwiftUI:Window 或 WindowGroup)。区分可拖动的标题栏区域与 NSWindow.title,用 NSToolbar 做统一的窗口外框(chrome),用 NSTitlebarAccessoryViewController 挂自定义标题栏控件,并保留原生窗口标签页和调整大小边缘。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my macOS window (NSWindow). Rule out: content underlapping the title bar because fullSizeContentView plus transparent title bar is set; the window not draggable where expected — isMovableByWindowBackground vs a draggable title bar area; keystrokes going nowhere because the first responder was cleared; frame autosave restoring an old position over your manual setFrame. The symptom:
调试我的 macOS 窗口(NSWindow)。排除以下可能:设了 fullSizeContentView 加透明标题栏,内容钻到标题栏下面;窗口在预期位置拖不动——isMovableByWindowBackground 与可拖动标题栏区域的区别;按键石沉大海,因为 first responder 被清掉了;frame 自动保存恢复了旧位置,盖掉你手动调的 setFrame。症状是:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| AppKit | NSWindow | |
| SwiftUI | WindowGroup | |
| SwiftUI | Window | |
| AppKit | NSWindowController |