Stepper 步进器 macos

Copies: 2

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

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

  1. 1 Increment button递增按钮 NSStepper.increment

    “The tiny upper arrow that raises the number” is the increment button.

    “上面那个把数字调大的小箭头”就是递增按钮。

    Prompt fragmentPrompt 片段

    the upper increment button of an NSStepper, increasing the bound value by NSStepper.increment

    NSStepper 的上箭头递增按钮,按 NSStepper.increment 的步长增大绑定值

  2. 2 Decrement button递减按钮 NSStepper.increment

    “The tiny lower arrow that reduces the number” is the decrement button.

    “下面那个把数字调小的小箭头”就是递减按钮。

    Prompt fragmentPrompt 片段

    the lower decrement button of an NSStepper, reducing the bound value by NSStepper.increment

    NSStepper 的下箭头递减按钮,按 NSStepper.increment 的步长减小绑定值

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

Place a native Stepper using NSStepper (SwiftUI: Stepper) beside the numeric field, with the compact up/down arrow pair vertically aligned to that field. Bind both controls to the same value and enforce the intended increment, minimum, and maximum.

用 NSStepper(SwiftUI:Stepper)把原生步进器放在数字输入框旁边,紧凑的上下箭头对与输入框垂直对齐。把两个控件绑定到同一个值,并约束好预期的步长、最小值和最大值。

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

Debug my macOS stepper (NSStepper, SwiftUI Stepper). Rule out: the stepper and its text field not bound to the same value so they drift; valueWraps looping from max back to min; autorepeat firing continuously while held when single steps were expected; a number formatter clamping or rejecting the value the stepper just set. The symptom:

调试我的 macOS 步进器(NSStepper、SwiftUI Stepper)。逐一排除:步进器和文本框没有绑定到同一个值,两边各走各的;valueWraps 让数值从最大值绕回最小值;想要单步调节,autorepeat 却在按住时连续触发;数字格式化器把步进器刚设的值截断或拒绝了。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
AppKit NSStepper
SwiftUI Stepper
AppKit NSStepper.increment
AppKit NSStepper.minValue
AppKit NSStepper.maxValue

See also相关词条