我正在NSTouchBar
使用情节提要为我的应用程序构建一个。
我想ESC
用其他东西替换按钮。
像往常一样,没有文档告诉你如何做到这一点。
我在网上搜索过,我发现了一些模糊的信息,比如
但是,您可以通过使用带有 NSTouchBarItem 的 escapeKeyReplacementItemIdentifier 将“esc”的内容更改为其他内容,例如“done”或任何内容,甚至是图标。
但这太模糊了,无法理解。
有任何想法吗?
这就是我到目前为止所做的。
我NSTouchBar
在情节提要上添加了一个按钮并将其标识符更改为newESC
. 我以编程方式添加了这一行:
self.touchBar.escapeKeyReplacementItemIdentifier = @"newESC";
当我运行应用程序时,ESC
键现在是不可见的,但仍占据栏上的空间。应该替换它的按钮出现在它旁边。所以那个酒吧
`ESC`, `NEW_ESC`, `BUTTON1`, `BUTTON2`, ...
就是现在
`ESC` (invisible), `NEW_ESC`, `BUTTON1`, `BUTTON2`, ...
旧ESC
的仍然占据它在酒吧的空间。