我有一个应用程序,其标准NSWindow
包含 aNSToolbar
和几个NSToolbarItem
s 作为首选项。s 设置为可选,并使用包含的NSToolbarItem
“模板”作为其名称的一部分,以获得漂亮的系统渐变效果。
However, when the NSToolbarItem
is selected, the selection does not change the background of the text.
每个都NSToolbarItem
被标记为可选择的,我NSToolbarDelegate
只实现了这两种方法:
-(NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar{
NSMutableSet *toolbarSet = [NSMutableSet set];
for (NSDictionary *prefItem in _preferenceItems){
[toolbarSet addObject:[prefItem objectForKey:@"toolbarIdentifier"]];
}
return [toolbarSet allObjects];
}
-(NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar{
NSMutableSet *selectableSet = [NSMutableSet set];
for (NSDictionary *prefItem in _preferenceItems){
[selectableSet addObject:[prefItem objectForKey:@"toolbarIdentifier"]];
}
return [selectableSet allObjects];
}
这就是我所看到的;注意文本周围的灰色框:
与 Safari 的首选项窗口相反:
我NSToolbarItem
在 Interface Builder 中的所有配置:
而它NSToolbar
本身: