• 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
WebView scroll tracking NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: Why do my posts not appear in cocoabuilder (cocoamamasam) ?
  • Next by Date: Re: One delegate's method doesn't work
  • Previous by thread: Re: One delegate's method doesn't work
  • Next by thread: modal panel (NSRunAlertPanel) _sometimes_ won't close
  • Index(es):
    • Date
    • Thread