Popover 弹出框(Popover) macos
A floating bubble whose arrow points back to the control that opened it
带箭头的浮动气泡,箭头指回打开它的控件
Now Playing
标本可交互 —— 点点看。Specimen is live — try it.
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Anchor arrow锚点箭头
NSPopover.show(relativeTo:of:preferredEdge:)“The little point on the bubble aimed at the button” is the anchor arrow.
“气泡上指着按钮的小尖角”就是锚点箭头。
Prompt fragmentPrompt 片段the NSPopover anchor arrow from show(relativeTo:of:preferredEdge:), pointing precisely at its source control
由 show(relativeTo:of:preferredEdge:) 生成的 NSPopover 锚点箭头,精确指向来源控件
-
2 Positioning rect定位矩形
NSPopover.show(relativeTo:of:preferredEdge:)“The exact bit of the button the bubble attaches to” is the positioning rect.
“气泡贴住按钮的那一小块位置”就是定位矩形。
Prompt fragmentPrompt 片段the positioning rect passed to NSPopover.show(relativeTo:of:preferredEdge:), anchoring the bubble to the intended part of the source view
传给 NSPopover.show(relativeTo:of:preferredEdge:) 的定位矩形,把气泡锚定在来源视图的预期位置上
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Present this as a Popover using NSPopover (SwiftUI: View.popover), with a visible anchor arrow aimed at the exact control that opened it. It should remain visually attached to that control and dismiss with native popover behavior.
用 NSPopover(SwiftUI:View.popover)把它呈现为弹出框,显示指向打开它的那个控件的锚点箭头。它要在视觉上始终附着于该控件,并按原生弹出框的行为关闭。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my macOS popover (NSPopover, SwiftUI View.popover). Rule out: transient behavior closing it on the first click inside custom content that does not accept first responder; the arrow anchored to a stale positioning rect after layout changes; the popover detaching into a floating window when dragged (detachable delegate); SwiftUI popovers presenting as sheets in compact contexts. The symptom:
调试我的 macOS 弹出框(NSPopover、SwiftUI View.popover)。逐一排除:transient 行为导致在自定义内容里点第一下就关闭——因为内容不接受第一响应者;布局变化后箭头还锚在过期的定位矩形上;弹出框被拖动时分离成浮动窗口(detachable 代理);SwiftUI 弹出框在紧凑上下文中以 sheet 形式呈现。症状是:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| AppKit | NSPopover | |
| AppKit | NSPopover.show(relativeTo:of:preferredEdge:) | positions the popover and its anchor arrow定位弹出框及其锚点箭头 |
| SwiftUI | View.popover(isPresented:attachmentAnchor:arrowEdge:content:) | |
| AppKit | NSPopover.Behavior |