Re: Positioning document within gray area of a scroller
Re: Positioning document within gray area of a scroller
- Subject: Re: Positioning document within gray area of a scroller
- From: Graham Cox <email@hidden>
- Date: Mon, 29 Jun 2009 09:56:23 +1000
On 29/06/2009, at 7:28 AM, Development wrote:
We are working on a document based application which displays the
document view within a scroller area. Like most similar programs,
the user can zoom in and out off the document (ie. we change the
view size of the document view). If he zooms out enough, our
document view becomes smaller then the area that the scroller
encloses. No problems so far. The scroll view draws a grey region
outside the area of our document region, and everything works fine.
We do not have to code any of this. However, our now small document
view is pinned to the lower left of area being shown by the scroller
view, instead of the upper left.
OK, you have described the default behaviour.
Has anyone been able to program this?
What is the question?
We asked this question at WWDC, and stumped several of the engineers.
What question?
We have tried all sorts of variations of configuration under
Interface Builder. We have set the isFlipped: method to different to
change where the origin is, and nothing seems to work. I know
people have asked this question here before, but there has never
been a good answer.
Our client is insisting that the document view should pin to the
upper left hand corner. This is the way Mac applications did it
under OS 9.
If the view that is inside the scroll view is overridden to return YES
for -isFlipped, it will pin to the upper left and not the lower left.
Of course that means your co-ordinate system in that view is also
flipped, but in many cases that's easier to handle anyway (or at least
more traditional). If you need unflipped co-ordinates but still pin to
the upper left, you'll have to handle the positioning yourself, which
requires a subclass of NSClipView. There is sample code on the web but
in doing this the other week I found that almost all the links point
to the same place, and the link is now dead.
More typically people want to centre the view when it becomes smaller
than the scroller (which is what I did). I did find the sample code
snippets at CocoaDev insufficient to fully handle this - for example
show/hide rulers didn't function correctly and nor did live resizing.
If you are interested in that code ask me off-list.
--Graham
_______________________________________________
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