FROM : Hasan Diwan
DATE : Fri Dec 24 22:30:40 2004
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 <hasan.<email_removed>>
DATE : Fri Dec 24 22:30:40 2004
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 <hasan.<email_removed>>
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

