Sheet 窗口附着面板(Sheet) macos

Documents

标本可交互 —— 点点看。Specimen is live — try it.

Anatomy — every part, named解剖 —— 每个部件的名字

  1. 1 Dimming layer变暗层 View.sheet(isPresented:content:)

    “The darkened area behind the sheet” is the dimming layer that marks the parent surface as temporarily unavailable.

    “Sheet 后面变暗的区域”就是变暗层,表示父界面暂时不可用。

    Prompt fragmentPrompt 片段

    the sheet's dimming layer (View.sheet(isPresented:content:)): the translucent dark overlay over the blocked parent surface behind the presentation

    Sheet 的变暗层(View.sheet(isPresented:content:)):覆盖在被阻挡父界面上的半透明暗色遮罩

Prompt — paste into your agentPrompt —— 直接粘贴给你的代理

Present this as a window-modal Sheet with NSWindow.beginSheet(_:completionHandler:) (SwiftUI: View.sheet), visibly attached beneath the parent window's title bar. Block only that parent window, not every window in the app.

用 NSWindow.beginSheet(_:completionHandler:)(SwiftUI:View.sheet)把它呈现为窗口级模态的 Sheet,视觉上附着在父窗口标题栏下方。只阻挡父窗口,不要阻挡 App 的所有窗口。

Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时

Debug my macOS sheet (NSWindow.beginSheet(_:completionHandler:), SwiftUI View.sheet). Rule out: the isPresented/item binding never reset so it will not present a second time; endSheet never called so the parent window stays blocked; presenting from a view controller detached from the window so nothing appears; two sheets queued on one window presenting back-to-back unexpectedly. The symptom:

调试我的 macOS Sheet(NSWindow.beginSheet(_:completionHandler:)、SwiftUI View.sheet)。逐一排除:isPresented/item 绑定从未复位,导致无法再次弹出;从未调用 endSheet,父窗口一直被锁;从已脱离窗口的视图控制器发起呈现,结果什么都不显示;同一窗口上排队的两个 Sheet 意外接连弹出。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
AppKit NSWindow.beginSheet(_:completionHandler:)
AppKit NSWindow.endSheet(_:returnCode:)
SwiftUI View.sheet(isPresented:onDismiss:content:)
AppKit NSApplication.runModal(for:) app-modal alternative, not a sheetApp 级模态的替代方案,不是 Sheet

See also相关词条