开发者

Cocoa - Rolling a panel out the side of a window?

I'm hoping this is ver straightforward. But basically I'd love for my app to be able to "roll out" a Panel/View to the right of my app's window.

I've achieved something similar (rolling a panel down, over the existing window) by doing:

[NSApp beginSheet:myPa开发者_开发百科nel
   modalForWindow: [self.view window]
    modalDelegate: self
   didEndSelector: @selector(sheetDidEnd: returnCode: contextInfo:)
      contextInfo: nil];

But how can I have a panel roll out the side of my window? I basically want to have like a sidebar, that if a user clicks the button, it will roll out + display more information. Does that make sense?

Thanks!


Couple of things (Edit: okay, three):

First, others suggested NSDrawer, but users were at best lukewarm on the idea of drawers years ago. These days drawers are nearly universally despised. Consider using NSSplitView (with the thin 1-pixel border) and use its -animator to animate the opening/closing.

Second, if you specifically want the "sheet" effect (a sheet appearing to come out of a slit in the window or even a view), you're in for a whole world of customization "fun" to reproduce this effect, since there's positively no public API to tell it to come out of a window/view vertically (vs. horizontally).

Third, I'd argue customizing a standard UI behavior in this way (the sheet example in my second point) is almost never the way to go. There are plenty of reasons to provide custom UI when the existing doesn't do what you need it to do, but making such an obvious change to standard behavior for the hell of it tends to be frowned upon by Mac users. It's one of the main complaints they have against third-party Windows apps (no consistency in their UI). So don't do the vertical sheet thing for your users' sake. :-)


If you want your panel to roll out away from the window - you should use NSDrawer. Otherwise - you'll have to code something custom and I don't think that it's going to be a good UX.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜