• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: HTML format Text Fields?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HTML format Text Fields?


  • Subject: Re: HTML format Text Fields?
  • From: Richard Adams <email@hidden>
  • Date: Fri, 31 Aug 2001 17:00:11 -0700 (PDT)

on 8/31/01 2:07 PM, Finlay Dobbie at
email@hidden wrote:

> See NSTextView, it's better than NSTextField for
this (and other things).
>
> -- Finlay
>
> On Friday, August 31, 2001, at 03:26 am, Richard
Adams wrote:
>
>> 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?

Thanks Finlay!

OK, I dove into NSTextView. It doesn't have much to
say about this, but luckily there is some info to be
gleaned from the TextEdit project sources in the
examples folder.

I got the following code to work:

- (IBAction)TestButton:(id)sender
{
NSURL *theURL;
NSURL *baseURL;
NSTextStorage *myTextStorage = [myTextView
textStorage];
NSMutableDictionary *options =
[NSMutableDictionary dictionary];
NSDictionary *docAttrs;
BOOL success;

baseURL = [NSURL URLWithString:
@"file:///Users/jra/test/"];
theURL = [NSURL URLWithString:
@"file:///Users/jra/test/index.html"];
[options setObject:baseURL
forKey:@"BaseURL"];

[myTextStorage beginEditing];
[myTextStorage readFromURL:theURL
options:options
documentAttributes:&docAttrs];
[myTextStorage endEditing];
}

It works great for very simple HTML. BUT, when I start
to get fancy (not really fancy, just not using really
simple HTML) and the thing just hangs. It certainly
didn't work with any of the web pages I had sitting
around to test it with. I'd be worried about sending
arbitrary - though perfectly legal HTML at it.

And I tried using an "http://..."; URL instead of a
"file://..." URL and it went into orbit as well.

This all looks like it *should* be useful, but there
are too many quirks and gotchas. That and the fact
that there is absolutely no documentation for it.

One more reason to go back to Swing/Java (I'm getting
*this* close to chucking Cocoa and sticking with Swing
and Java).

*** Rich ***
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com


  • Prev by Date: Re: Writing a custom spell service
  • Next by Date: NSButton in NSDrawer
  • Previous by thread: Re: HTML format Text Fields?
  • Next by thread: Please point me in the right direction for contextual menus
  • Index(es):
    • Date
    • Thread