Getting subviews to restore on NSSplitView collapse/uncollapse
Getting subviews to restore on NSSplitView collapse/uncollapse
- Subject: Getting subviews to restore on NSSplitView collapse/uncollapse
- From: Jay Koutavas <email@hidden>
- Date: Wed, 11 Jun 2003 17:14:56 -0700
I'm using a vertical NSSplitView and have a couple of questions
regarding resize and collapse of its contained views.
The problem:
------------
In the left-side-pane of my NSSplitView I have a subview with the x
origin set to a positive value (some left margin left space). The
subview's springs are set up to resize horizontally, no horizontal
struts. When I drag the splitview's divider to a size less then the
subview's x origin, and then drag it back out to its original
position, the subview's width gets greatly increased, right off the
side of the left-side-pane.
Some say a picture is worth a 1000 words. I have provided both. :)
The following are some ASCII-art pictures (best seen in a monospaced
font) that diagram the problem, where "SV" is the subview mentioned
previously:
1) At start, before resize:
+------------------+-+---------+
| left-side-pane | | right- |
| +-----+ | | side- |
| | SV | | | pane |
| +-----+ | | |
| | | |
+------------------+-+---------+
^ NSSplitView
|-- divider
2) Using the mouse, I drag the divider to the left of the subview's
(SV) left edge:
+--+-+-------------------------+
| | | right-side-pane |
| | | |
| | | |
| | | |
| | | |
+--+-+-------------------------+
3) using the mouse, I then drag the divider back out to its original position:
+------------------+-+---------+
| left-side-pane | | right- |
| +-------------| | side- |
| | SV | | pane |
| +-------------| | |
| | | |
+------------------+-+---------+
Note now how the subview's (SV) width is now different.
A Partial Solution...
----------------------
Well, this part of the problem isn't too perplexing. Clearly there's
some bad interaction going on somewhere in Cocoa-land when the
subview's width goes negative. I went Ahead and added a delegate that
handles NSSplitView's constrainMinCoordinate: and had it return a
minimum that was greater than the subview's left margin and I added a
canCollapseSubview: to the delegate that returns true so the user
could completely close off the left side of the split view. Works
dandy, the subview doesn't get whacked.
So, why did I start this newsgroup thread?
------------------------------------------
I couldn't leave well enough alone. My application also has a
programmatic means of toggling the collapse/uncollapse of the
left-side-pane. I do it by smooshing-down the width of left-side-pane
using a variation of the code found in OmniGroup's NSSplitView
category in their AppToolKit (their's is for top/bottom arrangements
-- which, btw, this problem exists for too). When programmatically
resized, regardless of what I am doing with constrainMinCoordinate:
and canCollapseSubview:, I end up with the "subview too wide" problem
as seen in diagram #2 above.
My Questions to the gentle readers of this newsgroup (and hopeful writers :)
----------------------------------------------------------------------------
1) Is there a way to programmatically call something that will result
in NSSplitView doing it's "constrainMinCoordinate" delegation
activity as it does on user drag when I programmatically collapse the
left-hand-pane?
2) Or is there some fundamental error in my approach, and there is a
much better way to do this that I simply haven't explored here?
3) Anyone willing to talk about why the subview's width gets so wide?
I really would like to avoid having to keep state info on the subview
and manually remove its horizontal stretchiness on collapse and then
restore it on uncollapse. That feels like a hack to me. Thus, my
questions. Hopefully I learn something from having asked.
Thank you for having taken the time to read this and triple-thanks to
those who end up replying.
best,
/jay
--
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Jay Koutavas
mailto:email@hidden
Heynow Software
http://www.heynow.com
Windham, New Hampshire, USA
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
_______________________________________________
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.