Skip navigation.
 
mlRe: NSPanel should not close on command-W
FROM : Georg Seifert
DATE : Sat Jun 21 19:10:32 2008

>

>> I just added a panel to my program. I do not want that the panel
>> closes on command-W. I did setBecomesKeyOnlyIfNeeded:YES. So It does
>> not close if there is a document window. But if the last one is 
>> closed
>> (with keyboard: command-W) also the panel closes.
>>
>> How do I prevent this?

>
> I am not sure I understand the exact issue, so I will suggest a few 
> options.
>
> 1. You can disable the close button on the panel, which should 
> prevent it
> being closed by the menu, but also prevents it from being closed at 
> all.
> Useful if you have (or are willing to implement) a show/hide toggle 
> menu for
> the panel.
>
> 2. If you just don't want the panel to respond to the close menu, 
> simply
> implement -validateUserInterfaceItem: in an appropriate place in the
> responder chain. The side effect here is that the close menu item 
> will be
> disabled any time the panel is key, which is probably OK as you have 
> it set
> up at the moment.
>
> 3. If you meant to say that when you close the last document window 
> that the
> panel closes at the same time, then I am not sure what that would 
> mean other
> than something is rather wrong.
>
> Just a general note: if the (red) close button on the panel is 
> enabled,
> users may expect that command-W will close it when it is made key. 
> There may
> also be a HIG issue with this.
>
> HTH,

Thanks for you suggestions.

I use the panel as a palette. Something like the systems font chooser. 
They have the close button enabled, but do not responde to close 
commands from the keyboard.

I could implement "windowShouldClose:" in the delegate but I do not 
know the source of the close event.

G

Related mailsAuthorDate
mlNSPanel should not close on command-W Georg Seifert Jun 21, 15:02
mlRe: NSPanel should not close on command-W Keary Suska Jun 21, 18:55
mlRe: NSPanel should not close on command-W Georg Seifert Jun 21, 19:10
mlRe: NSPanel should not close on command-W Marco Masser Jun 21, 19:10
mlRe: NSPanel should not close on command-W Keary Suska Jun 21, 19:40
mlRe: NSPanel should not close on command-W Georg Seifert Jun 21, 20:00
mlRe: NSPanel should not close on command-W Jason Stephenson Jun 21, 20:19
mlRe: NSPanel should not close on command-W Georg Seifert Jun 21, 20:25
mlRe: NSPanel should not close on command-W Andrew Merenbach Jun 21, 20:47
mlRe: NSPanel should not close on command-W Georg Seifert Jun 23, 09:35
mlRe: NSPanel should not close on command-W Mike Abdullah Jun 23, 16:17
mlRe: NSPanel should not close on command-W Jim Correia Jun 23, 17:18
mlRe: NSPanel should not close on command-W Andy Lee Jun 23, 17:31
mlRe: NSPanel should not close on command-W Georg Seifert Jun 23, 18:01
mlRe: NSPanel should not close on command-W Quincey Morris Jun 23, 20:06