Re: Imitating Behavior of a Sheet Window
Re: Imitating Behavior of a Sheet Window
- Subject: Re: Imitating Behavior of a Sheet Window
- From: Andy Lee <email@hidden>
- Date: Fri, 22 Jan 2010 15:47:22 -0500
On Friday, January 22, 2010, at 02:27PM, "Oleg Krupnov" <email@hidden> wrote:
>I'd like to create a window that would behave exactly as a sheet,
>except that it doesn't slide down from the window title bar, but fades
>in instead. The "sheet" should be modal, but the parent window should
>still be resizable and closable.
>
>For this reason (and also some others), I can't use [NSApp beginSheet:
>modalForWindow: modalDelegate: didEndSelector:]
Can you give an idea what the other reasons are?
>This works perfectly except for a single little problem. The title bar
>of the parent window and its "traffic light" window buttons are grayed
>our like if the parent window wasn't key window (which is true
>though).
>
>However, when a "natural" sheet is showing, the title bar of the
>parent window and the "traffic light" buttons are displayed normally,
>as if the parent window was the key window, even though the key focus
>is inside the sheet window.
>
>What is the trick I am missing that allows the natural sheet window to
>behave like this?
As a guess, I would try forcing the traffic light buttons to be enabled. NSWindow's standardWindowButton: method would give you the buttons. I'm uncomfortable enabling the close button when a window is displaying a document-modal sheet, but I'll leave that for people who are better at being HIG police to comment on.
I don't know if your pseudo-sheet is resizable, but if so, remember that real sheets stay centered horizontally within the parent window.
Note also there's a slight shadow at the top of a real sheet. For verisimilitude you might want to reproduce that shadow, bearing in mind that if Apple changes the appearance in an OS update you will then have a non-standard look.
Without knowing more about why you can't use a real sheet, I still wonder if you could make it work (assuming you can force the red close button to be enabled). There was a thread here recently about reducing the amount of time it takes for a sheet to slide down. Maybe you could set that to zero and apply your own fade-in and fade-out.
If you get really stuck making this work, could you give up the idea of looking like a sheet, and use a view that appears in the middle of your window, on top of everything else in the window? There are ways to hijack mouse clicks and keystrokes so the rest of the window is effectively disabled. One thing you'd lose is the ability to resize the window smaller than the "sheet."
Just some thoughts.
--Andy
>
>Thanks
>_______________________________________________
>
>Cocoa-dev mailing list (email@hidden)
>
>Please do not post admin requests or moderator comments to the list.
>Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>Help/Unsubscribe/Update your Subscription:
>
>This email sent to email@hidden
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden