Re: Scrollview sizing/positioning questions
Re: Scrollview sizing/positioning questions
- Subject: Re: Scrollview sizing/positioning questions
- From: Don Rainwater <email@hidden>
- Date: Thu, 3 Jun 2004 10:05:26 -0400
Yesterday, I did some complaining about NSView and NSScrollView (see
below), but "the air is the air" (obscure reference).
Here's what I did to get the scroll view to start at the top:
1. Create an outlet, myView, from MyController to the NSView inside the
NSScrollView.
2. Insert the following line into MyController's awakeFromNib:
[myView scrollPoint:NSMakePoint(0, NSHeight([myView bounds]))];
Not TOO terrible, but is this the best way?
Some previous posts had said something about subclassing NSView and
implementing isFlipped to return YES. I tried this, but the result was
that everything in the view was vertically flipped:
button
field
text
in Interface Builder became
text
field
button
when the program was run. This leads me to believe that isFlipped is
useful only if you need to change the coordinate system in a custom
view, then place things in that view.
On Jun 2, 2004, at 9:44 AM, Don Rainwater wrote:
[Xcode 1.2, Mac OS X 10.3.4]
The amount of information that I'm trying to display in a window
finally grew to where I needed to put it all in a scrollview. No
problem, I thought. In Interface Builder, I selected all of the text
fields and boxes, then selected Layout->Make subviews of->Scroll View.
This creates a scrollview that is *just* big enough to enclose all of
the objects within. It's a little tight, so I grab the edges of the
scrollview and make it bigger. Then I tried to move the enclosed
objects around. Grabbed a text field, dragged it to the right, it
starts to disappear.
Ok, so putting things into a scrollview actually puts them into an
NSView inside an NSScrollView, and resizing the scrollview doesn't
resize the view inside. But I found that I cannot reliably grab the
edges of the view and resize it like I did with the scrollview. In
some cases the edges disappear, but this is not entirely predictable.
What I discovered was that I had to set the auto-sizing bars to
springs on the inside of the scrollview AND on the inside of the view.
This allowed me to grow the view to the size that I need, move the
objects inside around, and add additional items to it. To get the
scrollview to scroll, I then had to change the springs of the view
back to bars, so that the view didn't resize itself when the enclosing
scrollview's size changed. This SORT OF makes sense.
After all that, the questions:
1. For getting a bunch of text fields and other items into a
scrollview, is this the "right" process, or did I construct a complex
solution to a problem with a simpler answer?
2. The scrollview works, but it starts at the bottom left of the view.
How can I make it start at the top right? And why would it default
to the bottom left anyway?
--
Don Rainwater
_______________________________________________
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.