Token Field 令牌输入框 macos
A text input that turns recognized values into removable rounded tokens
一种文本输入框,能把识别出来的值变成可移除的圆角令牌
标本可交互 —— 点点看。Specimen is live — try it.
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Token capsule令牌胶囊
NSTokenField.TokenStyle“The little rounded bubble around each recipient” is a token capsule.
「每个收件人外面那层圆角小气泡」就是令牌胶囊。
Prompt fragmentPrompt 片段an NSTokenField.TokenStyle token capsule wrapping one recognized value inside the field
一个 NSTokenField.TokenStyle 令牌胶囊,在输入框里包裹一个识别出的值
-
2 Selected token选中的令牌
NSTokenField“The whole pill that highlights before I delete it” is the selected token.
「删除前整个高亮的那粒胶囊」就是选中的令牌。
Prompt fragmentPrompt 片段the selected NSTokenField token with its native highlight, ready for keyboard deletion or editing
NSTokenField 中选中的令牌,带原生高亮,等待键盘删除或编辑
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Use a native Token Field (NSTokenField) with NSTokenField.TokenStyle so each recognized recipient or tag becomes a separately selectable, removable rounded token inside the editable field. Preserve token completion and keyboard deletion behavior.
使用原生令牌输入框(NSTokenField)和 NSTokenField.TokenStyle,让每个识别出的收件人或标签都变成可单独选中、可删除的圆角令牌。保留令牌自动补全和键盘删除行为。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my macOS token field (NSTokenField). Rule out: text not becoming tokens until Return because the tokenizing character set lacks your separator; represented objects vs display strings confused in the delegate so tokens show raw identifiers; completions never appearing because the completion delegate method is not implemented; copy producing plain text because writing represented objects to the pasteboard is unimplemented. The symptom:
调试我的 macOS 令牌输入框(NSTokenField)。排除以下可能:tokenizing character set 里缺了你的分隔符,导致按 Return 才把文本变成令牌;delegate 里把 represented object 和显示字符串搞混,令牌显示出原始标识符;没实现补全的 delegate 方法,补全列表永不出现;没实现向粘贴板写 represented object,复制出来只有纯文本。症状是:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| AppKit | NSTokenField | |
| AppKit | NSTokenField.TokenStyle | |
| AppKit | NSTokenFieldDelegate |