Re: Once again: Clickable hyperlink in NSTableView
Re: Once again: Clickable hyperlink in NSTableView
- Subject: Re: Once again: Clickable hyperlink in NSTableView
- From: Mattias Arrelid <email@hidden>
- Date: Wed, 6 Feb 2008 09:39:33 +0100
On 4 feb 2008, at 12.45, Johannes Fahrenkrug wrote:
Dear fellow developers,
I'm pretty new to both Cocoa programming and this list. I know the
following questing has been both asked and answered before, but I'm
still stuck.
I need to have a clickable hyperlink in one of my NSTableView columns.
I get the NSAttributedString to display nicely (blue and underlined),
but I can't click on it.
It seems as if my click never "reaches" the hyperlink.
I was - hopefully - pointed into the right direction here:
http://www.cocoabuilder.com/archive/message/cocoa/2006/3/16/158845
I tried the obove sample code in my
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)row
datasource method. Like I said: it's working as far as it's showing up
as a blue underlined string, just not clickable :(
My TableCell is of the type NSTextFieldCell.
You could subclass NSTextFieldCell, and in...
trackMouse:inRect:ofView:untilMouseUp:
...retrieve the attributed string from the yourself (the cell), asking
the attributed string it for it's link, and then open it using e.g.
[[NSWorkspace sharedWorkspace] openURL:anURL];
Or similar. Remember to return YES from trackMouse:... if you do
handle the event yourself.
Good luck
Mattias
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden