• 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: Scrolling Behavior of NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scrolling Behavior of NSTextView


  • Subject: Re: Scrolling Behavior of NSTextView
  • From: Dong Feng <email@hidden>
  • Date: Tue, 8 Jun 2010 07:56:18 +0800

Thanks for all your replies, Martin and Paul.

Martin, I tried the " [NSTextView scrollRangeToVisible:] with
NSMakeRange(0,0) ", but it is the same as to use [scrollPoint:] solely. Only
with [glyphRangeForTextContainer:] in prior the scroll-to-top works. I don't
think it is the problem of coordinate system flip-ness, because when using
[scrollPoint:] without [glyphRangeForTextContainer:], the text view does not
always scroll to bottom, either, it just does not always scroll to top under
certain window size and text length. And it seems not solely
[glyphRangeForTextContainer:] triggers the scroll-to-top because without
[scrollPoint:] the scrolling does not work, either.

Another minor wired problem is the trick of using both
[glyphRangeForTextContainer:] and [scrollPoint:] works only when you
drag-drop a NSScrollView in IB and then set the embedded custom view as
NSTextView. If an NSTextView is dragged and dropped directly (and IB
automatically embed it in a NSScrollView), the scroll-to-top does not work
even with the trick (and I haven't found a trick to make it work under such
situation).

Regards,
Dong



在 2010年6月8日 上午5:29,Martin Wierschin <email@hidden>写道:


> On 2010.06.07, at 2:10 PM, Paul Sanders wrote:
>
> I haven't looked at your code so I don't know what is going on in detail
>> but [NSLayoutManager glyphRangeForTextContainer:] performs layout, if it
>> hasn't been done already, which is probably why it is affecting the results
>> you get.  Until layout has been performed, the Cocoa text system doesn't
>> know the size of the text (in terms of the amount of space it will take up
>> on the display) and so (I surmise) scrollPoint: doesn't work as expected.
>>
>
> You're right about triggering layout, but there's no reason the text system
> should have any trouble with NSMakePoint(0,0). NSTextView and the Cocoa
> layout system always use a flipped coordinate system, so the origin is
> always top-left.
>
> Perhaps the problem is that once layout completes (or during layout), you
> (or Cocoa) is automatically scrolling the text view somewhere else? I'd
> break in the debugger to see if anything else is triggering unwanted
> scrolling.
>
> ~Martin
>
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Scrolling Behavior of NSTextView
      • From: "Paul Sanders" <email@hidden>
References: 
 >Scrolling Behavior of NSTextView (From: Dong Feng <email@hidden>)
 >Re: Scrolling Behavior of NSTextView (From: "Paul Sanders" <email@hidden>)
 >Re: Scrolling Behavior of NSTextView (From: Martin Wierschin <email@hidden>)

  • Prev by Date: Re: setting tab stops in a document
  • Next by Date: Re: [iPhone] -UIScrollView
  • Previous by thread: Re: Scrolling Behavior of NSTextView
  • Next by thread: Re: Scrolling Behavior of NSTextView
  • Index(es):
    • Date
    • Thread