2

I'm using a view based NSOutlineView with two different views (both views are custom subclasses of NSTableCellView). In the top level view I display a badge with a counter. The counter indicates the number of entries on the lower level. The counter is implemented as a rounded rect NSButton, following Apple's SidebarDemo project.

As you can see from the images the behaviour of the button upon selection of the cell is not the behaviour you would expect. My button turns black, while in Apple's sample it turns white. I've tracked down the method that sets this particular behaviour for a button to the setHighlightsBy method:

[[self.button cell] setHighlightsBy: 0];

I use the above in the awakeFromNib method of the custom cell class. In the same awakeFromNib I also set the button's bezel:

[[self.button cell] setBezelStyle: NSInlineBezelStyle];

The bezel style works just fine, but the highlighting seems to be ignored.

Further information I can give: The outline view uses bindings to gets its contents, its highlight mode is set to "Source List".

Why is my highlighting being ignored?

enter image description here

enter image description here

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Roger
  • 4,737
  • 4
  • 43
  • 68

2 Answers2

1

Is your button set up in IB (like in the demo project)? If so, do you have the "enable" box checked in the control section of the attributes inspector? I got the behavior you're seeing if I unchecked that box.

rdelmar
  • 103,982
  • 12
  • 207
  • 218
  • Yes, the button is set up in IB and its "enable" box is checked. It doesn't make any difference whether it's checked or not... – Roger May 06 '12 at 15:39
  • @Roger, it does make a difference in the demo project -- could it be that you're disabling the button somewhere else in your code? – rdelmar May 06 '12 at 15:43
  • Yes I checked the demo project and you're right. However I only reference that button in the awakeFromNib method on the cell view. Upon looking closer at it, it does look like it's being disabled somehow/somewhere as it looks disabled when it's not selected. – Roger May 06 '12 at 15:58
  • @Roger, if you click on your button does it select the row? I ask that because that will only happen if the button is disabled, otherwise the button receives the click rather than the cell. – rdelmar May 06 '12 at 16:04
  • Yes, when I click the button it selects the row. The button is definitely disabled. I subclassed NSButton with an implementation that overrides setEnabled:. When I set a breakpoint I can see in the stacktrace that NSEditorBinder is disabling my button. I don't understand why... – Roger May 06 '12 at 16:12
0

I found the cause of the described behaviour, thanks to the suggestion made by @rdelmar in his answer. The button is bound to the Cell View using the "Argument" binding inspector.

enter image description here

One of the settings there is "Conditionally sets enabled", which was enabled and apparently causes auto-disabling of my button. Once you disable this setting, the problem disappears.

Roger
  • 4,737
  • 4
  • 43
  • 68