Traffic Lights (Window Controls) 红绿灯按钮(窗口控制按钮) macos
The red, yellow, and green controls at the top-left of a macOS window
macOS 窗口左上角的红、黄、绿三个控制按钮
标本可交互 —— 点点看。Specimen is live — try it.
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Close button关闭按钮
NSWindow.ButtonType.closeButtonThe red control shows an x on group hover and closes the window rather than necessarily quitting the app.
红色按钮在整组悬停时显示 ×,它关闭窗口,但不一定退出 App。
Prompt fragmentPrompt 片段the red close button (NSWindow.ButtonType.closeButton): the left traffic light with an x hover glyph that closes the NSWindow
红色关闭按钮(NSWindow.ButtonType.closeButton):最左侧的红绿灯,悬停显示 ×,用于关闭 NSWindow
-
2 Minimize button最小化按钮
NSWindow.ButtonType.miniaturizeButtonThe yellow control shows a minus on hover and miniaturizes the window into the Dock.
黄色按钮悬停时显示减号,把窗口最小化到程序坞。
Prompt fragmentPrompt 片段the yellow minimize button (NSWindow.ButtonType.miniaturizeButton): the middle traffic light with a minus hover glyph that sends the window to the Dock
黄色最小化按钮(NSWindow.ButtonType.miniaturizeButton):中间的红绿灯,悬停显示减号,把窗口收进程序坞
-
3 Zoom / full-screen button缩放 / 全屏按钮
NSWindow.ButtonType.zoomButtonThe green control normally enters full screen; Option-click invokes the traditional window Zoom behavior instead.
绿色按钮默认进入全屏;按住 Option 点击则执行传统的窗口缩放(Zoom)行为。
Prompt fragmentPrompt 片段the green zoom button (NSWindow.ButtonType.zoomButton): show its full-screen hover glyph, enter full screen normally, and perform traditional window Zoom on Option-click
绿色缩放按钮(NSWindow.ButtonType.zoomButton):显示全屏悬停符号,默认进入全屏,Option 点击执行传统窗口缩放
-
4 Dirty-document dot未保存更改圆点
NSWindow.isDocumentEditedThe dark dot replacing the close button's x marks a document with unsaved changes.
替代关闭按钮 × 的深色圆点,表示文稿有未保存的更改。
Prompt fragmentPrompt 片段the dirty-document dot (NSWindow.isDocumentEdited): the dark center mark inside the red close button indicating unsaved changes
未保存更改圆点(NSWindow.isDocumentEdited):红色关闭按钮中央的深色标记,表示有未保存的更改
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Use the standard Traffic Lights from NSWindow.standardWindowButton(_:), preserving their native spacing, hover symbols, and the green button’s system-provided full-screen and window-arrangement behavior. Obtain the green control as .zoomButton and use NSWindow.toggleFullScreen(_:) only when explicitly invoking full screen; do not substitute custom circles.
使用 NSWindow.standardWindowButton(_:) 提供的标准红绿灯按钮,保留原生的间距、悬停符号,以及绿色按钮由系统提供的全屏和窗口排列行为。通过 .zoomButton 获取绿色按钮,只在明确要进入全屏时才调用 NSWindow.toggleFullScreen(_:);不要用自绘的圆点替代。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my macOS traffic lights (NSWindow.standardWindowButton). Rule out: buttons missing after changing styleMask or using borderless windows; hover glyphs gone because a custom titlebar accessory intercepts tracking; the green button zooming when you expected full screen (option-click zooms); repositioned buttons drifting after full-screen transitions because the themed frame re-lays them out. The symptom:
调试我的 macOS 红绿灯按钮(NSWindow.standardWindowButton)。逐一排除:改了 styleMask 或用了无边框窗口导致按钮消失;自定义 titlebar accessory 拦截了跟踪,悬停符号没了;期待全屏但绿色按钮执行了缩放(Option 点击会触发缩放);全屏切换后挪过位置的按钮被系统主题框架重新排布而漂移。症状是:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| AppKit | NSWindow.standardWindowButton(_:) | |
| AppKit | NSWindow.ButtonType | closeButton, miniaturizeButton, and zoomButtoncloseButton、miniaturizeButton 和 zoomButton |
| AppKit | NSWindow.toggleFullScreen(_:) | enters or exits a Space-filling full-screen window进入或退出占满一个空间的全屏窗口 |