Ordering of NSSplitView’s messages

With the iTunes 8.0.1, you can notice the Genius pane, which recommend songs you would have interest. What is interesting about the Genius pane is that its width doesn’t change when you resize the iTune’s window.
So, it ensures its minimum width. Although it is quite intuitive behaviour, NSSplitView’s default behaviour is not that intuitive. You can check this for yourself.
So, I wanted to implement similar behaviour. But it should work for the Mac OS X 10.4 Tiger also. It means that you can’t use

– (void)setPosition:(CGFloat)position ofDividerAtIndex:(NSInteger)dividerIndex

Then you can store its original width and keep setting the pane’s width to the saved original width.
But in what messages should you do so?
If you do it in splitViewDidResizeSubViews, it can be ensured when you resize its window. However, if you move the divider of your NSSliderView, which means that you want to change the sub-panes or sub-view’s width, it still sets the interested pane’s width to the original width. This is not what you want.

So, we need to figure out what messages are called in what order to differentiate the two cases.

This is for when a window itself is resized.

<< splitViewWillResizeSubviews
<< resizeSubviewWithOldSize
<<< splitViewDidResizeSubViews
… (repeated)

<< constrainMinCoordinate
<< constrainMaxCoordinate
<< canCollapseSubView
<< canCollapseSubView

This is for when a divider is moved. (A mouse button is pushed, then the mouse is moved, and released. )

<< constrainMinCoordinate
<< constrainMaxCoordinate
<< canCollapseSubView
<< canCollapseSubView

<< splitViewWillResizeSubviews
<<< splitViewDidResizeSubViews

<< constrainMinCoordinate
<< constrainMaxCoordinate
<< canCollapseSubView
<< canCollapseSubView

There are three things to consider.
The first is that resizeSubviewWithOldSize is called when the window is resized.
The second is that constrainMinCoordinate:, constrainMaxCoordinate, canCollapseSubView are called only after the splitViewWillResizeSubviews: and the splitViewDidResizeSubviews:.
The third is that each constrainMinCoordinate~canCollapseSubView set are called when a mouse button is pushed and released.

With those information, it will be possible to make any kind of behaviour.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: