Re: Imitating Behavior of a Sheet Window
Re: Imitating Behavior of a Sheet Window
- Subject: Re: Imitating Behavior of a Sheet Window
- From: Oleg Krupnov <email@hidden>
- Date: Fri, 22 Jan 2010 23:18:52 +0200
Thanks Andy.
Here's more info. The sheet is a semi-transparent nag window with some
text and a couple of buttons, that overlaps the main window. The sheet
does not have a shadow, so there is no problem to reproduce it. The
nag window is automatically resized together with the parent window so
that the nag always entirely shadows its parent. Also, it is not
critical to close the main window while the nag is showing, even
though it's "modal".
The reason that I don't want to use the standard sheet is that, as I
said, it slides down with animation, and when I tried to fiddle to cut
out the animation, the resulting behavior was quite buggy, so I wasn't
satisfied. I don't quite remember right now what exactly was buggy,
some kind of flickering I guess.
What confuses me is that the standard sheet methods are obviously
merely a convenience for showing the sheet windows, and there must be
a "manual" way to do it, but I can't find it.
The window buttons of the main window are not disabled, they just
behave like if the window wasn't active, i.e. they appear gray, but
when you move the mouse over them, they light up. So I don't think
forcing them to enable will change anything, because they are already
enabled, aren't they?
Before I switched to using the child window, I tried to use an
overlapping view, but I found it buggy too and quite clunky. And Cocoa
docs explicitly discourages using overlapping views.
I have fiddled a little more and also overrode the parent's window
isKeyWindow to always return TRUE. This works exactly like I want, but
now the parent window never looks inactive, even when I switch to
another application. And I can't seem to find a simple way to
discriminate when the window should return TRUE/FALSE in its
isKeyWindow.
Any ideas?
On Fri, Jan 22, 2010 at 10:47 PM, Andy Lee <email@hidden> wrote:
>
> 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