NSSplitView strange behavior
NSSplitView strange behavior
- Subject: NSSplitView strange behavior
- From: Vincent CARLIER <email@hidden>
- Date: Tue, 13 Aug 2013 15:43:19 +0200
Hi list,
I experience some strange behavior with NSSplitView.
Let me explain what I'm trying to do :
The split view contains 3 subviews (2 dividers), and has a delegate that
controls it. It is an horizontal split view.
Let number those 3 views from top to bottom 0, 1 and 2.
The upper divider has the default behavior, the two upper views (0 & 1)
should be resized.
I want the lower divider to behave differently, when dragged, view 1 should
not resize but instead views 0 & 2 should.
So, to achieve this, I implemented delegate methods :
-(void)splitViewDidResizeSubviews:(NSNotification *)notif;
-(void)splitViewWillResizeSubviews:(NSNotification *)notif;
In those methods, I inspect the userInfo dictionary, in order to react only
when the divider n°1 is dragged.
In the first method, I record the position of divider 0, as well as the
height of the third view :
_positionZero = NSHeight([view0 frame]);
_view2Height = NSHeight([view2 frame]);
In the second, I compute the difference between view2 successive heights,
and then move divider 0 by the same amount :
CGFloat view2HeightDelta = _view2Height - NSHeight([view2 frame]);
[[self splitView] setPosition:(_positionZero + view2Height)
ofDividerAtIndex:0]; // view2Height maybe positive or negative
Now, what happens ?
When I drag divider 1 down, all works as expected.
When I drag it up, it stops moving at what appears to be the return value
of -minPossiblePositionOfDividerAtIndex, for divider 0.
This shouldn't happen, as the min possible position is updated after the
call to -setPosition:ofDividerAtIndex:, which is confirmed by my logs.
But the divider stops moving at this limit, as if the split view was
looking only one time to this minimum, and never again (until I release the
mouse and then drag the divider again).
Anyone experienced something like this ?
Is there a better way to do what I'm trying to do ?
Any answer/advice is greatly appreciated.
Vince.
_______________________________________________
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