【发布时间】:2016-11-09 20:49:15
【问题描述】:
我正在尝试在编辑文本字段时将自定义触摸栏项目与触摸栏中的自动文本建议结合起来。
目前我正在自定义 NSTextView 类中覆盖 makeTouchBar,如果我不这样做,将为 textView 创建默认触摸栏。
这是主要的 makeTouchBar,我尝试在其中添加带有项目标识符 .candidateList 的建议,但没有运气:
extension ViewController: NSTouchBarDelegate {
override func makeTouchBar() -> NSTouchBar? {
let touchBar = NSTouchBar()
touchBar.delegate = self
touchBar.customizationIdentifier = .myBar
touchBar.defaultItemIdentifiers = [.itemId1,
.flexibleSpace,
.itemId2,
.itemId3,
.flexibleSpace,
.candidateList]
touchBar.customizationAllowedItemIdentifiers = [.itemId1]
return touchBar
}
}
谁能提供一个简单的例子来说明如何将这个词建议项添加到自定义触摸栏?
【问题讨论】:
标签: macos cocoa nstextview nstouchbar