I think I may have got this to work, so here goes: The data cell for the table column displaying the hyperlink is now a custom NSTextFieldCell with the following implementation over-ridden:
- (NSUInteger)hitTestForEvent: (NSEvent *)event inRect: (NSRect)cellFrame ofView: (NSView *)controlView { if([event type] == NSLeftMouseDown) { // User has clicked on the cell (assume for now that the entire cell is clickable). #ifdef DEBUG NSAssert([self attributedStringValue] != nil, @"There should be an attributed string value for this cell!"); #endif NSAttributedString *string = [self attributedStringValue]; NSSize stringSize = [string size]; NSPoint mouseLocation = [controlView convertPoint: [event locationInWindow] fromView:nil]; #ifdef DEBUG NSAssert((cellFrame.origin.y <= mouseLoc.y) && (mouseLoc.y <= cellFrame.origin.y + cellFrame.size.height), @"Click was not inside the cell rect!"); NSAssert(cellFrame.size.height == stringSize.height, @"The cell frame is not equal to the height of the cell name string!"); #endif if(cellFrame.origin.x + stringSize.width < mouseLocation.x) { // The mouse click missed the bounds of the displayed string, so don't open the URL. return NSCellHitNone; } NSRange stringRange = NSMakeRange(0, [string length]); NSURL *stringURL = [string attribute: NSLinkAttributeName atIndex: 0 effectiveRange: &stringRange]; #ifdef DEBUG NSAssert(stringURL != nil, @"A URL should be attached to every attributed string for this column!"); NSAssert([stringURL isKindOfClass: [NSURL class]], @"we didn't get a URL from the attributed string for this cell!"); #endif LSOpenCFURLRef((CFURLRef)stringURL, NULL); } return NSCellHitContentArea; } This still has the issue that the mouse won't change cursor when it enters the string's bounds, but at least the hyperlink actually opens now. Thanks for your help! ________________________________________ From: cocoa-dev-bounces+david.doyle=sophos....@lists.apple.com [cocoa-dev-bounces+david.doyle=sophos....@lists.apple.com] On Behalf Of Jerry Krinock [je...@ieee.org] Sent: 11 January 2010 19:30 To: cocoa-dev Subject: Re: Hyperlinks in Table Views This might help you: http://developer.apple.com/mac/library/releasenotes/cocoa/AppKitOlderNotes.html#NSTableView Note especially the section titled "NSTableView/NSOutlineView - Single click to edit" _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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/david.doyle%40sophos.com This email sent to david.do...@sophos.com 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 (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com