• 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: Using -scrollRectToVisible: in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using -scrollRectToVisible: in NSTextView


  • Subject: Re: Using -scrollRectToVisible: in NSTextView
  • From: Jeremy Dronfield <email@hidden>
  • Date: Tue, 6 Jul 2004 23:02:51 +0100

On 6 Jul 2004, at 5:19 pm, Douglas Davidson wrote:


On Jul 6, 2004, at 8:12 AM, Jeremy Dronfield wrote:

Are there any known issues with sending -scrollRectToVisible to NSTextView (or subclasses)?

I'm trying to get my text view to remember the visible rect for the last text file viewed, so that it can scroll back to that place when the same file is next loaded. I'm doing this:

I think you would probably be better off using scrollRangeToVisible: instead; otherwise you might need to manually force layout before scrolling.

Douglas Davidson


The reason I'm not using -scrollRangeToVisible: (which would be my first choice) is that there won't necessarily be a selected range to record at the point when the text is cleared for reloading (i.e. the user might have only been reading their text, not editing it). I hadn't thought that layout was a problem - at least so far as my testing goes, since the view frame isn't changing.

I'm thinking that -glyphRangeForBoundingRect:inTextContainer: might get me a range for recording, without there being any actual selection, as in

NSRange visibleGlyphs = [[textView layoutManager] glyphRangeForBoundingRect:[textView visibleRect] inTextContainer:[textView textContainer]];

followed by -characterIndexForGlyphAtIndex: or -characterRangeForGlyphRange:actualGlyphRange: I'd appreciate any tips you have for how to get this right. Xcode does it, so there must be a way.

Regards,
-Jeremy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Using -scrollRectToVisible: in NSTextView
      • From: Douglas Davidson <email@hidden>
References: 
 >Using -scrollRectToVisible: in NSTextView (From: Jeremy Dronfield <email@hidden>)
 >Re: Using -scrollRectToVisible: in NSTextView (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Objective-C and JDBC
  • Next by Date: Re: Using -scrollRectToVisible: in NSTextView
  • Previous by thread: Re: Using -scrollRectToVisible: in NSTextView
  • Next by thread: Re: Using -scrollRectToVisible: in NSTextView
  • Index(es):
    • Date
    • Thread