• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to toggle the subviews of a split view?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to toggle the subviews of a split view?


  • Subject: Re: How to toggle the subviews of a split view?
  • From: John Clayton <email@hidden>
  • Date: Sat, 14 Dec 2002 09:38:35 -0500

Hi Jacob,

Thanks for your help. I have a few more questions, too. I think my problem has not really been resizing the actual subview of the NSSplitView, that is what I'm doing. I get the superview of MyTabView, which is the direct subview of the split view, resize it, and then call adjustSubviews on the split view. From what you're saying, I realize that adjustSubviews is doing some proportional calculations that are overriding the width I have set the subview's frame to. But then you suggest
to set the frame sizes _exactly_ right, so the hights of the frames and the divider together fill the entire height of the BSSplitView
and this is where I get a little fuzzy. I know I can use the NSSplitView delegate method splitView:resizeSubviewsWithOldSize: to get at the frame sizes manually and block adjustSubviews from being called. Should I be doing all my own frame resizing and never call -adjustSubviews?


Also, Bertil Holmberg had a good suggestion:

I too ran into this behaviour and was far into writing my own version of
a splitview when I found a better way that seems to work with my setup
at least. The frame sizes are saved into the model class myData that is
archived. I have taken this bit of code out of its context and modified
its private names to make it more general, hopefully without introducing errors...

- (void)closeSplitView
{
[myData setTopFrame:[topContainer frame]]; // save top frame
[[bottomContainer retain] removeFromSuperview]; // remove bottom view
[splitView adjustSubviews];
}

- (void)openSplitView
{
[splitView addSubview:[bottomContainer autorelease]]; // restore
bottom view
[topContainer setFrame:[myData topFrame]]; // restore top frame
[splitView adjustSubviews];
}

Hope this helps,

Bertil

Except that in my case, I need to leave the view in place, because I want the tabs sticking out from the left, as if just the tab view were docked. I guess I should summarize what I'm doing:

I have a vertical split view, with horizontal split view in the right pane and a right-vertical tab view in the left pane, very much like ProjectBuilder. Both are enclosed in custom views. When the user clicks an active tab in the left tab view, i resize it's enclosing subview so that the tabs doc to the left of the window, by setting a new width. I open the tab view in a similar manner. Both the split view and that tab view are in place when the window wakes up, so I am just resizing here.

I wonder if this describes the situation well enough? Anyway, thanks for any insight you may have.


-John



On Friday, December 13, 2002, at 08:31 PM, Jacob Engstrand wrote:

John Clayton wrote:

I use the
outermost custom view in the subview to do the resizing, I get it's
frame, create a new rect with the width I want, and then set the frame
to the new rect. Seems like it should work, but logging tells me that
the final resized frame has a different width than the one I have set.
Hmmm.


This used to drive me mad, too. Until I realized that you need to set the sizes of the actual subviews of the split view. Sort of like this (myTableView is one of the two things I put in the split view):


[[[myTableView superview] superview] setFrame: myFrame];

Since the first superview of a table view is a clip view and the next is the scroller, and it is the scroller that is the direct subview of the NSSplitView and is the one you need to set.

For a textedit, it is even worse:

[[[[myTextEdit superview] superview] superview] setFrame: myTextEditFrame];


Of course, remeber to set the frame sizes _exactly_ right, so the hights of the frames and the divider together fill the entire height of the BSSplitView. (But I guess you already knew that, huh?)

Also, be sure to let the window resize itself _before_ calculating the frame sizes and calling -adjustSubviews (like if you open the Window and resize it programatically before showing, you dont want to call -adjustSubviews in the windowDidLoad or awakeFromNib.)

Hope this helps. (Someone please tell me if I'm wrong! I'd actually like to be wrong in this case! :)

/jak

_________________________________________________________
Magician. Have rabbit. Will travel.
_______________________________________________
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.


Regards,

John Clayton
email@hidden
----------------------------------
Ask a question, remain a fool for five minutes
Don't ask a question, remain a fool forever
_______________________________________________
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.

  • Follow-Ups:
    • Re: How to toggle the subviews of a split view?
      • From: Jacob Engstrand <email@hidden>
References: 
 >Re: How to toggle the subviews of a split view? (From: Jacob Engstrand <email@hidden>)

  • Prev by Date: NSData (again!)
  • Next by Date: Appropriate Behavior of Text Box and Drop-Down?
  • Previous by thread: Re: How to toggle the subviews of a split view?
  • Next by thread: Re: How to toggle the subviews of a split view?
  • Index(es):
    • Date
    • Thread