Re: Table view tooltips crashes when using NSString with attachment characters?
Re: Table view tooltips crashes when using NSString with attachment characters?
- Subject: Re: Table view tooltips crashes when using NSString with attachment characters?
- From: Keith Blount <email@hidden>
- Date: Fri, 1 Sep 2006 02:31:09 -0700 (PDT)
Sorry to respond to my own post so quickly, but I have
found a solution for this. After more testing, it
seems that it wasn't the attachment character that was
causing problems after all. What was happening was
that the strings in question had been created from
text storages with only images and whitespace in them.
So there was no text to draw in the tooltip. I tested
this out by just returning @"\n\n\n\n" for the
tooltip, as follows:
- (NSString *)tableView:(NSTableView *)aTableView
toolTipForCell:(NSCell *)aCell
rect:(NSRectPointer)rect tableColumn:(NSTableColumn
*)aTableColumn row:(int)row
mouseLocation:(NSPoint)mouseLocation
{
return @"\n\n\n\n";
}
The above code will cause a hang. Strangely, it
appears that returning an empty string (@"") is fine,
but returning a string with only whitespace in it
causes as crash. I guess the internal methods check
the length and upon finding a length > 0, try to use
something like
-boundingRectForSize:options:attributes: (which I know
causes a hang in these circumstances), which then
chokes when it can't calculate anything. I think I'll
log this as a bug. Anyway, for now I have created a
category on NSString that ensures there is some text
within the string for drawing, as follows:
- (NSString *)drawingString
{
return ([self rangeOfCharacterFromSet:[NSCharacterSet
alphanumericCharacterSet]].length > 0) ? self : @"";
}
Thanks anyway,
Keith
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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