Re: URLs in TextView
Re: URLs in TextView
- Subject: Re: URLs in TextView
- From: Dan Wood <email@hidden>
- Date: Wed, 09 May 2001 08:54:08 -0700
Here's what I put in my awakeFromNib for my about box to specify the
text, as HTML so that I get a hot link. Yes, as far as I know, it can
only be done programatically. It works great, but the only problem is
that I don't know if there's a way to change the cursor to a "hand"
while over the link, as you'd expect.
- (void) awakeFromNib
{
NSString *html=@"<html><font face=\"Lucida Grande\"><b><a
href=\"
http://www.karelia.com/museo/\">
http://www.karelia.com/museo/</a></b>
</font></html>";
NSData *theData = [html dataUsingEncoding:NSUTF8StringEncoding];
NSAttributedString *text
= [[[NSAttributedString alloc]
initWithHTML:theData documentAttributes:nil] autorelease];
[oURL setDrawsBackground:NO];
[oURL setEditable:NO];
[[oURL textStorage] setAttributedString:text];
}
I don't know about displaying of more complex data -- I suppose you mean
embedded images? I tried to do embedded images too, but I didn't get
very far. Perhaps it will work with a local file:// URL for an image,
but not an http:// URL?
Good luck, and let us know if you make any more progress!
On Tuesday, May 8, 2001, at 06:32 PM, email@hidden wrote:
Hi,
I'm trying to setup a NSTextView with some non-editable text that
contains some URLs. In IB, I drop a NSTextView, then using the list
view, remove the scroller. After adjusting the alpha of the background
color, I'm left with a transparent NSTextView. Great. That's step one.
Now my problems begin:
- There doesn't seem to be a way to specify the text. What am I
missing? Can it only be done programatically?
- How would I go about specifying a link? There's a tantalizing
textView:clickedOnLink: delegate message, but it doesn't tell me how to
specify a link in the first place. What's the secret?
- Possibly on the same topic, how would I go about displaying some
simple HTML data, kinda like Mail does for HTML emails?
Anyone got any idea or pointers to more complete documentation?
Arno.
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
--
Dan Wood
email@hidden
http://www.karelia.com/
http://www.bikealameda.org/
Mac OS X Developer: Online Resume:
http://www.karelia.com/resume.html