Re: Displaying HTML in an NSTextField
Re: Displaying HTML in an NSTextField
- Subject: Re: Displaying HTML in an NSTextField
- From: Rush Manbert <email@hidden>
- Date: Tue, 19 Sep 2006 16:19:50 -0700
a.d. jensen wrote:
In an attempt to do some debugging, I'd like to see the source code of
a webview. So, I've implemented this code:
---
WebDataSource *dataSource = [[webView mainFrame] dataSource];
NSString *myString;
if ([[dataSource representation] canProvideDocumentSource])
{
myString = [NSString stringWithString:[[dataSource representation]
documentSource]];
}
else
{
myString = [NSString stringWithCString:"Cannot get text
representation" encoding:NSASCIIStringEncoding];
}
[sourceEdit setStringValue: myString];
---
When the page loads, nothing shows up in the text field (though, if
there's something in there already, it's erased.) If I drop into the
debugger, I can see the source in "myString" (though truncated, which
is why I'm trying to put it in a scrolling text field in the first
place) and if I change the line that assigns into myString to be a
"stringWithCString", the text field is updated properly.
So, my guess is that the NSTextField is interpreting the web page
source code and just not displaying it properly (or rendering it, or
something). Any ideas on what to do to make it display properly (or
tell me how wrong my guess is :-)
When I do this I use a NSTextView, and set its content with setString,
so my last line would be:
[textView setString:myString];
I don't know why you're having problems setting the contents of the
NSTextField, but you might try this instead.
- Rush
_______________________________________________
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