Re: Single-click words in NSTableView / NSTextFieldCell
Re: Single-click words in NSTableView / NSTextFieldCell
- Subject: Re: Single-click words in NSTableView / NSTextFieldCell
- From: Tony P <email@hidden>
- Date: Fri, 9 Apr 2010 14:52:28 +0100
Thanks for that Corbin. That's fine and dandy, except I'm still stuck
in identifying the "link" word. There are multiple "link" words or
phrases in each cell, so I don't know which one has been hit without
some kind of characterIndexForPoint functionality. Or perhaps I can't
see the wood for the trees?
Tony
On 8 Apr 2010, at 5:34 pm, Corbin Dunn wrote:
On Apr 8, 2010, at 8:17 AM, Tony P wrote:
Hi Folks,
I'm trying to implement single-clicking for multiple words/phrases
within an NSTableView / NSTextFieldCell, which seems surprisingly
tricky. I've tried using NSAttributedString (in the hope I can use
a special NSURLProtocol to intercept the hyperlink), but it takes
four clicks to get there (row select, cell select, edit, and link-
click). I've tried numerous tricks but to no avail.
I can over-ride hitTestForEvent (see the "Hyperlinks in Table
Views" thread) so the other alternative would be some way of
getting characterIndexForPoint for the NSTextFieldCell, but that
doesn't seem to exist. I'm hoping I don't need to do something
wacky with an off-screen view.
How can I get the NSTextFieldCell to react with just one click? Or
is there a way to get characterIndexForPoint for the NSTextFieldCell?
You'll have to implement the logic in an NSTableView subclass.
Override -mouseDown:, grab the cell at the mouse location, look at
the cell's contents to see if you hit a link, and if so, do your
link stuff. If not, call super for the default selection/tracking/
editing behavior to take place.
corbin
_______________________________________________
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