NSImageCell: Set ToolTip

1.9k views Asked by At

I'm trying to show a tooltip on the mouse hover at a NSImageCell. I've tried setting the property on Interface Builder (both on the NSImageCell and the NSTableColumn that contains it) but it didn't work.

Any ideas?

3

There are 3 answers

0
mikywan On BEST ANSWER

I solved this by overriding this method in the controller for my NSOutlineView:

- (NSString *)outlineView:(NSOutlineView *)outlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn item:(id)item mouseLocation:(NSPoint)mouseLocation;
0
user3510720 On

In case of NSTableView you can use

(NSString *)tableView:(NSTableView *)tableView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation;
0
jscs On

Neither NSCell nor NSTableColumn will display tool tips, because neither is a subclass of NSView. You will have to set the tool tip on the table view itself.

You can use -[NSView addToolTipRect:owner:userData:] to set a tool tip for a particular area of a view. In combination with -[NSTableView frameOfCellAtColumn:row:], you ought to be able to set up a different one for each cell.