如何获得源列表选择突出显示使用OS X 10.10中的黑暗的活力外观? [英] How to get the source lists selection highlight to use the Dark Vibrancy appearance in OS X 10.10?

查看:187
本文介绍了如何获得源列表选择突出显示使用OS X 10.10中的黑暗的活力外观?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在OS X 10.10中,源列表似乎使用 light 活力外观。在Finder(以及一些其他第三方应用程序,例如Things.app)中,源列表中的所选项目由暗的振动外观指示。例如,请参阅下面图片中的桌面行。



如何复制此行为?我需要使用委托方法指定表行视图,

  -outlineView:rowViewForItem:

并尝试自定义绘图自己或有更直接的方法吗?如果在Xcode中创建标准源列表UI,则默认高亮显示仍然是我们在以前版本的OS X中看到的标准蓝色矩形。



原来,当我使用NSTableViewSelectionHighlightStyleSourceList,并点击我的NSOutlineView外面,我会得到Finder突出显示样式。



只需让你的NSOutlineView成为一个子类,并覆盖这个方法:

   - (BOOL)acceptsFirstResponder {
return NO;
}

它有效,但有些缺点。例如,使用NSOutlineView中的箭头键将不再工作。我下载了Things应用程序,它不允许使用箭头键,所以很可能这是他们是如何做。如果有人找到更好的方式,请张贴。


In OS X 10.10 source lists seem to use the light vibrancy appearance. In the Finder (and in some other third party applications, Things.app for example) the selected item in the source list is indicated by a dark vibrancy appearance. For example, see the Desktop row in the image below.

How can I replicate this behaviour? Do I need to use the delegate methods to specify the table row view,

-outlineView:rowViewForItem:

and attempt custom drawing myself or is there a more straight forward approach? If you make a standard source list UI in Xcode the default highlighting is remain the standard blue rectangle that we have seen in previous version of OS X.

解决方案

After playing around for a while I found a way to accomplish this. It turned out that I would get the "Finder highlight" style when using NSTableViewSelectionHighlightStyleSourceList and clicking outside my NSOutlineView. So I figured it would stay that way if you refuse making it first responder.

Simply make your NSOutlineView a subclass and override this method:

-(BOOL)acceptsFirstResponder{
    return NO;
}

It works, but with some downsides. For example, using arrow keys in the NSOutlineView will no longer work. I downloaded the Things app, and it does not allow use of arrow keys either, so it's very likely that this is how they are doing it. If anyone finds a better way, please post it.

这篇关于如何获得源列表选择突出显示使用OS X 10.10中的黑暗的活力外观?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆