resize problems

Hi all,
I’ve got a problem which can be easily recreated in Interface Builder:

  1. Create a new window
  2. Place an object (for example an NSScrollView) in the bottom of the window
  3. Set the autoresize options to resize with the window in all directions
  4. Choose “TestInterface” (command-R) from the File menu and try resizing the window to very small
    You’ll see that when you resize to a more normal size, the object will be misplaced.

Any one have solved this problem?

I know I can set a minimum size on the window, but: I want to use splitviews and they do not have a minimum size…

John

The problem is not in how the objects are drawn, but in how you’re not dealing with this as a view’s default behavior. It’s not the computer’s responsibility to make sure that all the objects fit in the window, it’s your’s.

It is a common occurrence that budding asstudio developers limit themselves to what’s handed to them by apple in the IB palette’s, the doc’s, and the objects supported in the asstudio terminology. Split views DO have settings for minimum and maximum sizes, as well as other methods that allow for a great deal of customization. At the top of the split view terminology section in the asstudio docs, there is a link to the NSSplitView cocoa class from which all of the AS actions and commands are derived. This is true of 99% of all objects in the ASS terminology ref. Not only will you find methods that represent all of the actions found in asstudio, you will usually find many more methods that do lots of other cool things that the apple folks writing headers to support asstudio commands haven’t gotten around to incorporating yet. This is where you must look to find all of the features that you wish you had but don’t have access to when relying solely on what’s available in asstudio alone.

To add the features you want you need to do a couple of things. First, you need to decide what the absolute minimum dimensions of the window can be, and then set that in the min/max size fields in the window’s IB size pane. Views like table views and outline views can not be resized in such a way that their content overlaps their header or their top overlaps their bottom. This is where you’ll get your wierd rendering behavior, and it can’t be overcome other than by limiting their size, position, and resizing habits. Next, you’ll need to create a custom subclass of NSSplitView, and put some methods in there that override the default split view methods… which I’ve outlined next…

The obj-c code below is taken directly from one of my current projects. In that project, I have a left/right split view that uses three NSSplitView methods to customize it’s behavior. The first two define the minimum and maximum sizes a particular subview can resize to. The third I use to control the size of the left subview when the window is resized. When the window frame changes, only the right subview changes size, the left maintains it’s width, and can only be resized by the user using the divider handle. I also threw in a fourth method that restricts whether a particular subview can be collapsed or not. It’s sometimes nice to ensure that some or all subviews can’t be collapsed, and this is the way to do it.

There’s a lot more to what’s available to you, if you take the time to broaden your horizons and not be scared to use some obj-c in your apps.

Good luck,
j