Scroll View (Scroller) 滚动视图(Scroller) macos
A viewport whose AppKit scrollbar is called a scroller
一个视口,它的滚动条在 AppKit 里叫 scroller
标本可交互 —— 点点看。Specimen is live — try it.
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 ScrollerScroller(滚动条)
NSScrollerThe control most people call a scrollbar is formally a scroller in AppKit.
大多数人叫「滚动条」的那个控件,在 AppKit 里正式名称是 scroller。
Prompt fragmentPrompt 片段the scroll view's scroller (NSScroller): the native macOS track-and-thumb control at the content edge
滚动视图的 scroller(NSScroller):内容边缘的原生 macOS「轨道+滑块」控件
-
2 Scroller knob (thumb)滚动滑块 knob(thumb)
NSScroller.knobProportion“The little thumb you drag” is the scroller knob; its length reflects how much content is visible.
「那个能拖的小滑块」就是 scroller 的 knob,它的长度反映可见内容占多大比例。
Prompt fragmentPrompt 片段the scroller knob or thumb (NSScroller.knobProportion): the draggable rounded piece whose length represents the visible fraction of content
滚动滑块 knob(thumb,NSScroller.knobProportion):可拖动的圆角小块,长度代表内容的可见比例
-
3 Knob slot (track)滑块槽 knob slot(轨道)
NSScroller.drawKnobSlot(in:highlight:)The channel behind the knob is the knob slot, commonly called the scrollbar track.
knob 后面的滑槽就是 knob slot,通常叫滚动条轨道。
Prompt fragmentPrompt 片段the scroller knob slot or track (NSScroller.drawKnobSlot(in:highlight:)): the channel behind the draggable knob
scroller 的滑块槽(轨道,NSScroller.drawKnobSlot(in:highlight:)):可拖动 knob 后面的滑槽
-
4 Overlay vs. legacy scrollerOverlay 与 legacy 两种 scroller 样式
NSScroller.StyleAn overlay scroller fades over the content; a legacy scroller stays visible and takes up layout space.
overlay scroller 浮在内容上、闲置淡出;legacy scroller 一直可见并占用布局空间。
Prompt fragmentPrompt 片段the scroller style (NSScroller.Style): overlay floats above content and fades when idle, while legacy remains visible in reserved space
scroller 样式(NSScroller.Style):overlay 浮在内容上方、闲置时淡出;legacy 在预留的空间里常驻可见
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Use a native Scroll View (NSScrollView; SwiftUI: ScrollView). In AppKit, call the edge control an NSScroller, with its draggable knob inside the knob slot; respect NSScroller.Style overlay versus legacy and preserve native scroll elasticity at the content boundaries.
使用原生滚动视图(NSScrollView;SwiftUI:ScrollView)。在 AppKit 里,边缘那个控件叫 NSScroller:可拖动的 knob 位于 knob slot 之内;尊重 NSScroller.Style 里 overlay 与 legacy 的区别,并在内容边界保留原生的滚动弹性。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my macOS scroll view (NSScrollView, NSClipView). Rule out: content origin confusion because the document view is not flipped; overlay vs legacy scroller styles changing available width between users; the rubber-band overscroll disabled or doubled by elasticity settings; wheel events swallowed by a nested scroll view; scrollToVisible fighting responsive-scrolling prefetch. The symptom:
调试我的 macOS 滚动视图(NSScrollView、NSClipView)。排除以下可能:document view 没有 flipped 导致内容原点搞反;overlay 和 legacy 两种 scroller 样式让不同用户看到的可用宽度不一样;橡皮筋过冲被 elasticity 设置禁用或叠了双倍;滚轮事件被嵌套的滚动视图吞掉;scrollToVisible 和响应式滚动预取互相打架。症状是:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| AppKit | NSScrollView | |
| AppKit | NSScroller | |
| SwiftUI | ScrollView | |
| AppKit | NSClipView |