I’m using a drawer for the first time in an app. The drawer’s edge is “Bottom”. The content width and height is 500 X 500. The leading offset is 10 and the trailing offset is 270. The main window’s size is 800 X 140 and it isn’t resizable. The issue with my app is that when I tell the drawer to open, it slides down from top of the main window. When I close the drawer, it slides up, beyond the top of the main window and then disappears . Is there a setting that controls the Y position from which the drawer should animate in?
Are you setting that stuff in code, or in IB? IB has a lot of controls for drawers I think.
tried setting the offsets to 0? Maybe the 270 is doing something odd.
I don’t think your offsets are the problem. I think you’re trying to flaunt the Human Interface Guidelines in two ways here. Drawers are not supposed to be bigger than their parent windows. Even though your drawer is narrower than your window, it’s much deeper. If you think about a real drawer in a bureau, the drawer can’t be deeper, and I think that Apple probably wanted their drawers to look like real drawers. Whether this is Apple’s way of telling you not to do this, or more likely, just an unintended consequence of the way drawers were implemented, I don’t know. Secondly, as Shane and I pointed out in this post, macscripter.net/viewtopic.php?id=37471 , the current guidelines discourage the use of drawers in new apps, suggesting using panels or popovers instead.
Ric
After Edit: After duplicating your behavior, it looks like what is really going on with drawers, is that when you open one, it appears suddenly, then moves in an animated way to its open position. Normally, you don’t see the open suddenly part because the drawer is hidden behind your window – that’s why, in your case, the drawer appears above the window then moves down, and reverses that behavior when it closes. This is why they can’t be bigger than their window and still look right.
Thanks Ric. I switched everything to use a panel. I liked the way a drawer functions, especially the way it moves with the window, which a panel doesn’t.
You can attach a panel to a window so that it moves when the window moves, but if you move the panel the window doesn’t move. With a window called win and a panel called aPanel, this will do it:
win's addChildWindow_ordered_(aPanel,current application's NSWindowAbove)
You can set up the relative position of the 2 windows in IB or in code. The NSWindowAbove means that the panel will appear on top of the window if they overlap.
Ric
Thanks Ric. That did the trick