WebView scroll tracking NSTextView
WebView scroll tracking NSTextView
- Subject: WebView scroll tracking NSTextView
- From: Hasan Diwan <email@hidden>
- Date: Fri, 24 Dec 2004 13:30:40 -0800
I'm not sure this is entirely possible, but I have written a web
editor with live preview using an NSTextView and a WebView. I keep the
content in sync using the following code:
- (void)textDidChange:(NSNotification *)aNotification {
NSTextView *editor = [aNotification object];
[[webView mainFrame] loadHTMLString:[editor string] baseURL:nil];
}
I guess I need to obtain the NSPoint of the edit in the view, map that
to where that is rendered, and scroll to it. The most difficult part
is the second. How do I programmatically map where a given edit will
render in the WebView?
NSView has a scrollToPoint: method. I assume this will work with a
WebView as well?
I can get the location of the edit using NSTextInput's
firstRectForCharacterRange giving it the range of the change and
obtaining the NSPoint from the resulting NSRect. Is there a better
way to do this? Thanks in advance for the help! Happy Christmas!
--
Cheers,
Hasan Diwan <email@hidden>
_______________________________________________
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