NSTextView minus NSScrollView equals frameRect movement wierdness
NSTextView minus NSScrollView equals frameRect movement wierdness
- Subject: NSTextView minus NSScrollView equals frameRect movement wierdness
- From: Mikey <email@hidden>
- Date: Wed, 15 May 2002 01:30:01 -0500
I'm working on the venerable synchro-scrolling problem where you have
multiple NSTextViews, and all of them share a single NSScroller that
scrolls them in unison.
I figured that the most efficient way to do this would be to make all my
NSTextViews into subviews of a custom NSView, and then wrap that NSView
with an NSScrollView. Since I don't have any examples to follow in
implementing this, I'm finding it to be quite a challenge.
In particular, NSTextViews behave very strangely when they're not directly
wrapped with an NSScrollView: they slowly crawl out of the visible portion
of their super view as you add text to them! Since this kind of weirdness
is hard to describe, here's a simple way to see it for yourself:
1) Start Interface Builder.
2) Create a new Cocoa application.
3) Drag a custom view to your application's window.
4) Set the custom view to be an NSTextView.
5) Select "Test Interface" under the "File" menu.
6) Put the insertion point in the NSTextView and type the
following:
1<return>
2<return>
3<return>
4<return>
5<return>
etc.
As the text view grows to accommodate your typing, it will start to slide
down the window, leaving what will look like a trail of 1s behind -- the 1s
appear to be some kind of drawing artifact left behind as the NSTextView
moves.
This is all quite amusing until you actually have to figure out how to fix
it. To try to figure out what was going on, I created a subclass of the
NSTextView and logged calls to the following methods: -setFrameOrigin: and
-setFrameSize:. As expected, the -setFrameSize: method was called when the
NSTextView grew to accommodate added text, but in addition, the
-setFrameOrigin: was also being called with offsets that were twice the
size of the size changes. This makes absolutely no sense to me, but
somehow, an NSScrollView must know how to deal with it.
Can anyone explain this or point me to some documentation that will help me
understand it -- code examples would be even better since I'm sure that I'
ll have other questions once this one is licked ;)
Michael Sullivan
email@hidden
_______________________________________________
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.