NSTextView enclosing scroll view jumps on spacebar
Asked Answered
P

2

1

I have an odd behavior with my app and I don't know where it comes from. I have implemented a NSScanner for a text view content that works very well. The scanner works in conjunction with the text storage to set attributes on the text storage string via text view delegate methods. However, each time I enter a space, the enclosing scroll view scrolls back to the top of the text view. Can anyone give me a hint where this comes from ?

Physiography answered 23/7, 2011 at 22:16 Comment(0)
P
4

Probably not much hassle for those more experienced than me, I found out the possible reason for this behavior (see above) so I post it here in case anyone will look for solutions for similar "problems". It seems that turning off "Non-contiguous layout" option in the XCode 4.x attributes inspector for the NSTextView in case will solve the problem. The documentation for NSLayoutManager provides more clues (under "Overview" section): "Noncontiguous layout is an optional layout manager behavior new in Mac OS X v10.5..."

Maybe somebody more experienced than me will provide more info on this and the reason of this behavior of the enclosing scroller view when non-contiguous option is checked (which is, by default).

Physiography answered 25/7, 2011 at 11:37 Comment(0)
C
1

I am stuck with the same problem and turning off "Non-contiguous layout" does solve the problem, but it gives rise to another problem which is that the NSTextView gets sluggish for 10k lines of text. A similar question has been answered differently but I wonder if it works. That solution also imposes some restrictions which may not be applicable to you though.

Cerography answered 29/12, 2011 at 9:40 Comment(1)
I finally found out when exactly it happens and have elaborated it at https://mcmap.net/q/1400345/-modifying-nstextstorage-attributes-causes-scroll-view-to-jump-aroundCerography

© 2022 - 2024 — McMap. All rights reserved.