Window with Drawer resizing problem

I am creating a drawer for the first time. I think I finally understand how it all works. I have a window and a drawer and a menu item that toggles the drawer open and closed. The problem I have is that my main window is resizable (and I want it to be), and the drawer is affecting the minimum size that the main window can be resized to. If I make the window big, open the drawer and then try to make the main window smaller, it won’t keep shrinking, it stops. If I manually close the drawer part way, I can then shrink the window a little more. The size of the drawer seems to affect how small the main window can get. I don’t want this. I have experimented with the drawer size properties and can’t come up with anything that fixes this.

Any ideas what else I should be looking at?

Model: iMac Intel
Browser: Safari 525.20.1
Operating System: Mac OS X (10.5)

From a design standpoint, would you want the drawer to close when the main window size is sized smaller than the drawer allows? Could you have the drawer automatically close? (That might take some Objc?) Have it automatically close the drawer when the user drags the window below a certain pixel size.

Ideally, I wanted to set a minimum and maximum size to the main window that would work with the drawer open or closed at any of the legal sizes. Maybe what I am actually looking for is a way to make the drawer size down with the window, as opposed to the drawer just getting shorter but essentially remaining the same width.

I am already constraining the main window during its resize with this code:

on awake from nib theObject
	--Set up proportional resize of windows
	set {winWidth, winHeight} to size of theObject
	set winProportion to (winWidth / winHeight)
end awake from nib

on will resize theObject proposed size proposedSize
	set {tmpWidth, tmpHeight} to proposedSize
	return {tmpWidth, (tmpWidth / winProportion)}
end will resize

Any ideas how I might also manipulate the drawer size in that on will resize handler?

Model: iMac Intel
AppleScript: XCode 3.0
Browser: Safari 525.20.1
Operating System: Mac OS X (10.5)

Ended up not making the drawer resize. It looks like the window can’t be smaller than the drawer so I went with a set small drawer size. Now the window can be sized down pretty small.

One change. Have the proportion set on awake from nib worked great until I added a second window. The proportion was set to the size of the second window, which was no good when resizing the first window. I ended up putting the proportion into the resize itself. Anyone see any problem with doing it this way? It seems to be working:

on will resize theObject proposed size proposedSize
	set {winWidth, winHeight} to size of theObject
	set {tmpWidth, tmpHeight} to proposedSize
	return {tmpWidth, (tmpWidth / (winWidth / winHeight))}
end will resize

AppleScript: xCode 3.0
Browser: Safari 525.20.1
Operating System: Mac OS X (10.5)

Here’s a different approach you may want to consider. Instead of the drawer, why not have that be a separate window or panel? Then the main window could resize without the drawer’s constraints. You could make the panel snap to the edge of the main window and move around with the main window if it’s necessary to keep the two together. I’ve never done it but I’ve seen it done this way.

Oh, that would be pretty cool. Don’t know if I will have time to rethink my approach but I would like to know how to do it.

I guess the first main window would have the on resize event affect the second window as well. How would the second window move around with the first one? Is there a link in Interface Builder that would cause it to “snap” to the other window or would you have to do it with handlers in the script, always calculating a new X,Y value for the 2nd window based on the 1st?

Model: iMac Intel
AppleScript: xCode 3.0
Browser: Safari 525.20.1
Operating System: Mac OS X (10.5)

I imagine it would have to be done with code in the main window’s “resized” handler as you mentioned.

One other approach… you could put a split view in your main window. Then inside the left view of the split view you could put your main window’s contents, and in the right half of the split view you could put your drawer’s contents. This way it’s all in one window, and the right-half of the split view could be opened or closed just like the drawer would be.

I use this split view approach in my application ScriptLight. You can see it on my website if you want to see how I implemented it.