I am using several NSButtonCell objects in an NSTableView. They are simple square buttons with custom images on them.
我在NSTableView中使用了几个NSButtonCell对象。它们是简单的方形按钮,上面有自定义图像。
These buttons draw properly when they are not highlighted: all that is visible is the image, and the rest of the button rectangle is transparent. However, when I click on them, the entire button rectangle is highlighted, inverting the background in the parts that were transparent.
这些按钮在未突出显示时正确绘制:所有可见的是图像,按钮矩形的其余部分是透明的。但是,当我单击它们时,整个按钮矩形会突出显示,反转透明部分的背景。
I would prefer to see the image drawn inverted, and the transparent parts remain transparent. How can this be done?
我宁愿看到倒置的图像,透明部分保持透明。如何才能做到这一点?
2 个解决方案
#1
8
Try setting your cell's highlightsBy
property to NSContentsCellMask
. I think you'll have to do this in code (probably in awakeFromNib
); I don't see a way to do it in IB alone.
尝试将单元格的highlightBy属性设置为NSContentsCellMask。我想你必须在代码中执行此操作(可能在awakeFromNib中);我没有看到单独使用IB的方法。
#2
1
You can do it in Interface Builder too. I use "Square Button
" so the button alters between two images (so the image is not inverted at all).
您也可以在Interface Builder中执行此操作。我使用“方形按钮”,因此按钮在两个图像之间改变(因此图像根本不会反转)。
Your buttons behaviour is probably set to "Momentary Light
" or "Momentary Push In
".
您的按钮行为可能设置为“瞬间光”或“瞬间推入”。
Set the Behaviour
to "Momentary Change
", and it should work.
将行为设置为“瞬间变化”,它应该工作。
#1
8
Try setting your cell's highlightsBy
property to NSContentsCellMask
. I think you'll have to do this in code (probably in awakeFromNib
); I don't see a way to do it in IB alone.
尝试将单元格的highlightBy属性设置为NSContentsCellMask。我想你必须在代码中执行此操作(可能在awakeFromNib中);我没有看到单独使用IB的方法。
#2
1
You can do it in Interface Builder too. I use "Square Button
" so the button alters between two images (so the image is not inverted at all).
您也可以在Interface Builder中执行此操作。我使用“方形按钮”,因此按钮在两个图像之间改变(因此图像根本不会反转)。
Your buttons behaviour is probably set to "Momentary Light
" or "Momentary Push In
".
您的按钮行为可能设置为“瞬间光”或“瞬间推入”。
Set the Behaviour
to "Momentary Change
", and it should work.
将行为设置为“瞬间变化”,它应该工作。