Trouble with Leopard's newly enhanced NSSplitView
Trouble with Leopard's newly enhanced NSSplitView
- Subject: Trouble with Leopard's newly enhanced NSSplitView
- From: Frank Reiff <email@hidden>
- Date: Tue, 18 Dec 2007 10:05:11 +0100
Right, I've decided to take the plunge and the next major release of
my main app will be Leopard only.. as I'm going through the Leopard
feature list, I'm trying to eliminate as much custom code with
standard Leopard-features as at all possible and taking advantage of
new capabilities that I now get for free.
I've been thinking about using RBSplitView for a while, but I'm not
keen on relying too much on third-party code after being boxed-in by
MOKit for a while. Now the new Leopard NSSplitView is supposed to be a
much more satisfactory implementation than the old one, so I decided
to give it a go.
Unfortunately, I can't figure out how to do what I need with it. The
documentation is still a bit bare-bones, so perhaps I've overlooked
something.
What I want is a three view (2 vertical splitters) with the central
view being of fixed size, e.g.
<-->| |<-->
When I pull the left splitter towards the right, the left view should
get bigger, the central view stay the same size and the right view get
smaller, e.g.
<--->| |<->
When I pull the left splitter towards the left, the left view should
get smaller and the right view larger:
<->| |<--->
At some stage when it gets too small the left view should collapse:
| |<------>
The right view should have a minimum size and not collapse.
The behavior of the right splitter should be:
<->| |<---> (when dragged to the left)
<--->| |<-> (when dragged to the right)
The essential thing is that the central view should "slide" around.
I can't for the life of me figure out how to do this. The views don't
have max and min widths, so it all comes down to implementing this in
the NSSplitView delegate methods. The problem is that I need to move
the position of BOTH splitters simultaneously to get the central view
to keep a constant width. The only place I can find to do this in is
the delegate method that gets called during the splitter drag:
- (CGFloat)splitView:(NSSplitView *)sender constrainSplitPosition:
(CGFloat)proposedPosition ofSubviewAt:(NSInteger)offset;
I calculate the correct next position of the second splitter based on
the proposedPosition of the first splitter and then set this via:
[splitView setPosition: x ofDividerAtIndex: theOtherSplittersIndex];
Unfortunately, this results in that same method being called for that
second splitter and the adjustment being executed before the first
call is finished. So by the time that the "proposedPosition" for the
first splitter has been applied, the second splitter has already been
changed and the views have been resized accordingly. This produces an
offset which is taken up by the splitter itself. After the drag of the
first splitter is finished, the second splitter has become wider and
this can get up to 200 pixels wide :-(
What am I doing wrong? Is this even possible with Leopard's
NSSplitView? Can RBSplitView handle this more gracefully?
I guess what I'd need would be some way of changing both splitters
simultaneously instead of applying one new position after the other..
Any insights would be much appreciated.
Best regards,
Frank
_______________________________________________
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