Reputation: 2094
I'm making an Cocoa app for Yosemite.
I added a view based NSTableView in Interface builder, but the border 2 pixel width and thicker than Yosemite's Finder's. And the cell selection color is blue, while Yosemite's Finder's is gray.
And this is how Yosemite's Finder's table view looks like.
I checked the settings in Interface Builder.
The super scroll view of NSTableView's frame setting is (0,0,149,257):
While the Clip View's frame setting is (1, 1, 147, 255) and can not be changed.
And how to make a same NSTableView as Yosemite's Finder's?
Thanks a ton!
Upvotes: 7
Views: 5133
Reputation: 76
To whoever wants to remove the NSTableView border...
My requirement was to remove the border colour of the NSTableView so that, it should look like a white box. Tried all properties and forums but couldn't find a way to do that. Finally I came up with a dirty hack in the Storyboard which could fix the problem. If someone have a better option, please let us know.
-2
. so that the NSTableView border will be outside of the BoxLeft=2
, Top=2
, Bottom=-2
and Right=-2
Thats it.
Upvotes: 0
Reputation: 7496
In my experience selected rows are still painted blue, even when the "Source List" highlight style is selected. To avoid that, I needed to prevent the table or outline view from becoming the first responder by subclassing it and adding
- (BOOL)becomeFirstResponder {
return NO;
}
Edit:
Turns out becomeFirstResponder
is actually important if you want to support keyboard navigation. I have found a better solution that does not override becomeFirstResponder
.
First, create a custom NSTableRowView
subclass with an (overridden) empty setEmphasized:
method:
- (void)setEmphasized:(BOOL)emphasized {
// This avoids a blue background when selected in a source list that has first responder status.
}
You can then provide an instance of your custom NSTableRowView
class by implementing
- (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row
in your NSTableViewDelegate
.
Upvotes: 2
Reputation: 6918
The Finder sidebar isn't a table-view it's a Source List NSOutlineView
:
The border is applied around the enclosing scroll view:
Note also that a standard NSOutlineView
lets you adjust the highlight style from within Interface Buider:
Upvotes: 13