Hi all;
I'm trying to display a list of clickable hyperlinks inside a table view. The
current approach I'm taking is to use a table column with a NSTextFieldCell
data cell, with a value attribute that is bound to an attributed string value,
constructed in a value transformer:
- (id)transformedValue: (id)value
{
NSString *siteURL = @"http://example.org";
NSString *siteDisplayString = (NSString *)value;
NSMutableAttributedString *hyperlink = [[NSMutableAttributedString alloc]
initWithString: siteDisplayString];
NSRange range = NSMakeRange(0, [siteDisplayString length]);
[hyperlink beginEditing];
[hyperlink addAttribute: NSLinkAttributeName
value: [NSURL URLWithString: siteURL]
range: range];
[hyperlink addAttribute: NSForegroundColorAttributeName
value: [NSColor blueColor]
range: range];
[hyperlink addAttribute: NSUnderlineStyleAttributeName
value: [NSNumber numberWithInt: NSSingleUnderlineStyle]
range: range];
[hyperlink addAttribute: NSFontAttributeName
value: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize:
NSSmallControlSize]]
range: range];
[hyperlink endEditing];
return [[hyperlink copy] autorelease];
}
This value transformer is used to transform an array of strings. This
particular value transformer works well when transforming a single string for
use in an NSTextField. My problem is that this hyperlink won't respond to
mouseDown: events in the table view unless the cell is edited, which isn't the
behaviour I want (it should open the hyperlink with a single click, and the
table column shouldn't be editable). Am I missing something from this approach?
Failing that, is there a different (better?) approach of displaying a list of
hyperlinks?
Thanks in advance,
David
________________________________
Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United
Kingdom.
Company Reg No 2096520. VAT Reg No GB 348 3873 20.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]