Re: Odd tooltip behavior in NSTableView
Re: Odd tooltip behavior in NSTableView
- Subject: Re: Odd tooltip behavior in NSTableView
- From: Dustin Wenz <email@hidden>
- Date: Thu, 16 Jun 2005 09:41:00 -0500
Thanks for the info! That's one thing I need to get better at is to
double check the stuff that's being passed into delegate methods.
In my case, it's probably not necessary to test for NSTextFieldCell
because anything that inherits from NSCell will automatically
implement stringValue, which returns an empty string if it does not
apply (and the tooltip manager will treat it as if it were nil).
There is also some strangeness when comparing the
attributedStringValue width to the column width... Frequently a cell
in a table column will adjust it's character kerning to force a
better fit when possible. This has the effect of displaying a tooltip
in some situations when the entire string is already visible. For
consistency, it's probably better to always show the tooltip whether
the text appears truncated or not.
I still have my original problem though. If I click too many times in
the tableview, the toolTipForCell method stops getting invoked. Any
more thoughts? This is kind of freaking me out.
- .Dustin
On Jun 15, 2005, at 5:36 PM, Corbin Dunn wrote:
I have an nstableview with a modest number of rows and columns.
Some of the cell contents can be quite long, so I need a tooltip
to display the entire cell contents when the cursor hovers over
it. Should be trivial right? I just implement this in my delegate:
- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:
(NSCell *)aCell rect:(NSRectPointer)rect tableColumn:
(NSTableColumn *)aTableColumn row:(int)row mouseLocation:(NSPoint)
mouseLocation
{
return [aCell stringValue];
}
This is a little cleaner:
- (NSString *)tableView:(NSTableView *)tv toolTipForCell:(NSCell *)
cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc row:
(int)row mouseLocation:(NSPoint)mouseLocation {
if ([cell isKindOfClass:[NSTextFieldCell class]]) {
if ([[cell attributedStringValue] size].width > rect-
>size.width) {
return [cell stringValue];
}
}
return nil;
}
--corbin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden