HTML format Text Fields?
HTML format Text Fields?
- Subject: HTML format Text Fields?
- From: Richard Adams <email@hidden>
- Date: Thu, 30 Aug 2001 19:26:19 -0700 (PDT)
I noticed that HTML formatted text is showing up what
look like maybe NSTextFelds - for example I created a
file, sample.html, in emacs, double clicked it in the
Finder and it opened up in TextEdit. It was displayed
as nicely formatted HTML.
So, I got to thinking that I'd like to have have HTML
formatted text in my app too. I dug around a bit and
noticed the initWithHTML method in NSAttributedString.
This sorta works. I tried the code below (this is a
method called in response to clicking a button next to
a NSTextField called myTextField):
- (IBAction)Button4:(id)sender
{
NSAttributedString *attributedString;
NSData *someData;
NSURL *theURL;
theURL = [NSURL URLWithString:
@"
http://www.google.com/index.html"];
someData = [NSData dataWithContentsOfURL: theURL];
attributedString = [NSAttributedString alloc];
attributedString = [attributedString initWithHTML:
someData documentAttributes: nil];
[myTextField setAttributedStringValue:
attributedString];
}
This *almost* works. I get something sometimes. If I
click int he NSTExtField, I get the plain text from
the page.
Does anyone know anything about this method and making
it work?
Alternately, any better ideas for displaying simple
HTML output?
** Rich ***
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com