Re: Links in NSTextField
Re: Links in NSTextField
- Subject: Re: Links in NSTextField
- From: Michael Nickerson <email@hidden>
- Date: Fri, 25 Aug 2006 08:14:58 -0400
On Aug 24, 2006, at 9:19 PM, PGM wrote:
I remember that when I tried it (about a year ago so I do not
remember all specifics), it only worked when the textField was
editable, which would be a bit of a nuisance for the user. I tried
several other approaches, but in the end I just made a normal
NSTextField with blue underlined text and overlayed a transparent
button with an action that used NSWorkspace to load the URL.
Unfortunately that does not give the nice handcursor.
Patrick
On 24-Aug-06, at 16:18 PM, Uli Kusterer wrote:
Am 24.08.2006 um 16:47 schrieb Michael Nickerson:
It works with an NSTextField. Set its attributed string value.
You then just need to set it to be selectable (you can keep it
non-editable), otherwise it doesn't respond to clicks.
I actually tried that first, but not only didn't it trigger the
link, it lost the link style as soon as I clicked it. :-(
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
OK, apologies to the list. Apparently, I've been coding in my
sleep. I recently tried this out, and *thought* I was using a
textfield, but apparently at some point I did actually switch it over
to a textview.
Since I can never leave anything well enough alone, I made a subclass
of NSTextField that will handle clicks on links. And give you the
hand cursor over links (on 10.3 and later - the hand cursor isn't
available on 10.2 and earlier, though the textfield will still work
in 10.2 at least). The only setup you need to do is to set the
attributed string, and set the textfield to be non-editable and non-
selectable.
Code is free to use, hope y'all enjoy it. :)
<http://www.nightproductions.net/developer.htm>
(DSClickableURLTextField)
Darkshadow
(aka Michael Nickerson)
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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