Re: Odd tooltip behavior in NSTableView
Re: Odd tooltip behavior in NSTableView
- Subject: Re: Odd tooltip behavior in NSTableView
- From: Manuel Riess <email@hidden>
- Date: Sat, 15 Oct 2005 23:05:23 +0200
Hi!
Does anyone have a solution for the problem that the toolTipForCell
method of a tableView is only called two or three times?
I have the same problem in my application. The tooltips are working
fine, when I add or remove a line from the table, and any row is
selected. Once I click outside the tableView, the tooltips are not
working anymore. Even if I select a row in the table, the tooltips won
´t show up. If a row is added then, the tooltips work again, until I
select any rows 2 or 3 times or click anywhere else in the window.
Any ideas?
Thanks,
Manuel
Am 16.06.2005 um 16:41 schrieb Dustin Wenz:
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
_______________________________________________
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