在基于视图的NSTableView上自定义右键单击突出显示 [英] Customize right click highlight on view-based NSTableView

查看:188
本文介绍了在基于视图的NSTableView上自定义右键单击突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于视图的NSTableView,其中包含一个自定义NSTableCellView和一个自定义NSTableRowView.我定制了这两个类,因为我想更改每行的外观.通过实现[NSTableRowView draw ...]方法,我可以更改背景,选择,分隔符和拖动目标突出显示.

I have a view-based NSTableView with a custom NSTableCellView and a custom NSTableRowView. I customized both of those classes because I want to change the appearance of each row. By implementing the [NSTableRowView draw...] methods I can change the background, the selection, the separator and the drag destination highlight.

我的问题是:当右键单击该行并显示菜单时,如何更改显示的突出显示?

My question is: how can I change the highlight that appears when the row is right clicked and a menu appears?

例如,这是规范:

我想将方形高光更改为圆形,如下所示:

And I want to change the square highlight to a round one, like this:

我想可以通过调用诸如drawMenuHighlightInRect之类的方法在NSTableRowView中完成此操作,但是我找不到它.另外,如果我在子类中自定义所有绘制方法,并且不调用超类,则NSTableRowView类将如何执行此操作?这是由表格本身绘制的吗?

I'd imagine this would be done in NSTableRowView by calling a method like drawMenuHighlightInRect: or something, but I can't find it. Also, how can the NSTableRowView class be doing this if I customized, in my subclass, all of the drawing methods, and I don't call the superclass? Is this drawn by the table itself?

经过更多的实验,我发现可以通过将tableview设置为源列表来实现圆形突出显示.尽管如此,我想知道如何自定义它.

After some more experimenting I found out that the round highlight can be achieved by setting the tableview as a source list. Nonetheless, I want to know how to customize it if possible.

推荐答案

我来看看NSTableRowView

I'd take a look at the NSTableRowView documentation. It's the class that is responsible for drawing selection and drag feedback in a view-based NSTableView.

这篇关于在基于视图的NSTableView上自定义右键单击突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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