Binding value for NSTableView, but tooltip gets set as well
I've set up an NSTableView
in Interface Builder to be populated from an NSArray
. Each value of the array represents one row in the table. The value is bound correctly, but as a side effect, the table cell's tooltip is set to the string representation of the bound object.
In my case, the NSArray
contains NSDictionary
objects and the开发者_如何学Go tooltip looks like it could be the [... description]
output of that dictionary. Very ugly...
I don't want the tooltip to be set at all. I have other tables that have plain NSString values bound to them and they don't have a tooltip set automatically. Is there some Interface Builder magic going on? I tried to start with a blank project - same problem.
I should add that the table cell is a custom implementation of NSTextFieldCell
that uses an NSButtonCell
instance to draw an image and a label into the table. The values are retrieved from the dictionary bound as value.
Why is the tooltip set when I only bind the "value" attribute?
Thanks in advance!
Fixed. Here's what happened:
- I used a custom NSTextFieldCell to draw the table cell
- The value was bound do an NSDictionary instance
- The actual cell value was magiaclly set to the string representation of the dictionary. It was not visible, because I used a custom cell.
NSTableView can draw a special tooltip-like window and show the cell's contents if that does not fit into the cell.
- For my custom cell that was the case.
Disabling this can be done by implementing the NSTableViewDelegate method:
- (BOOL)tableView:(NSTableView *)tableView
shouldShowCellExpansionForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
return NO;
}
精彩评论