Reputation: 488
When a stock NSTableView's row/cell is selected, its background becomes blue and any standard NSTextfields text color becomes white.
Is there a public API that lets you to get a message when an encapsulating row view or cell view is selected? Basically, I want to make a custom view that changes colors when the row/cell is selected.
Upvotes: 1
Views: 104
Reputation: 90551
Table cells don't get selected, table rows do. NSTableRowView
has a selected
property.
I think you should just rely on your view being asked to draw (i.e. being marked as needing display) when the row changes whether or not it's selected. It can then query the properties of its enclosing row view to decide how it should draw.
That said, you shouldn't necessarily use the selected
property of the row to decide how to draw. Rather, you often should use the interiorBackgroundStyle
of the row. Or, if you're using NSTableCellView
for your cell view, check its backgroundStyle
. In many case, you won't have to check; the cell view will forward the setting of backgroundStyle
to its subviews, if they support that.
Upvotes: 1
Reputation: 826
You can make use of NSTableViewDelegate . You can use tableViewSelectionDidChange for that. Please refer this https://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSTableViewDelegate_Protocol/#//apple_ref/occ/intfm/NSTableViewDelegate/tableViewSelectionDidChange: .
Upvotes: 1