Re: Tooltips in NSTableView
Re: Tooltips in NSTableView
- Subject: Re: Tooltips in NSTableView
- From: Brian Webster <email@hidden>
- Date: Tue, 29 Jan 2002 00:09:46 -0600
On Monday, January 28, 2002, at 10:39 PM, cocoa-dev-
email@hidden wrote:
Since the first got me a cell, I tried :
if ([[tableColumn identifier] isEqualToString:@"Name"]){
NSString* theToolTip = [NSString stringWithFormat:@"Name
column, row=%i", row];
[[cell controlView] setToolTip:theToolTip];
This doesn't seem to work
This is because the setToolTip: method sets a single tooltip for
the entire NSTableView, so each time you call it you just
replace what was there before.
What you should do is to call addToolTipRect:owner:userData: on
the NSTableView in your awakeFromNib method (the docs for this
method are in the NSView class). Then, whenever the mouse moves
over the table view, the owner object you pass in will have its
view:stringForToolTip:point:userData: method call. You can use
the point along with NSTableView's columnAtPoint: and
rowAtPoint: methods to determine the cell, and return the
appropriate tooltip. Assuming your table view will shrink and
grow in size, it's probably easiest just to add a single
enormous rectangle to track so that it will always encompass the
whole table view.
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster