Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you press <kbd>Command</kbd> + <kbd>W</kbd>, it's the exact same as choosing <code>File -&gt; Close</code> from the menu bar. What <code>Close</code> does is send a <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/performClose:" rel="noreferrer"><code>performClose:</code></a> message to the first responder. That, in turn, will check if the receiver or if the receiver's delegate implements <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/windowShouldClose:" rel="noreferrer"><code>windowShouldClose:</code></a>, and the window will close if it returns <code>YES</code> (otherwise, it will call the <code>close</code> method).</p> <p>So really, it depends on what type of dialog you've got here. If it's non-modal (essentially, if you can access the menu bar while it's running) and is an instance or subclass of <code>NSWindow</code>, then all you need to do is override the <code>windowShouldClose:</code> method in your dialog's delegate (or your dialog class, if you subclassed <code>NSWindow</code> or something) and make it return <code>YES</code>.</p> <p><strong>However</strong>, if the dialog is a modal dialog (you can't access the menu bar, switch windows, etc. while the dialog is running), then you can't do it this way. You <em>could</em> add an invisible button, but in all honesty, a modal dialog should not be closed by hitting <code>Command-W</code>, for that most certainly violates some Apple interface guideline out there. (Especially since, as Ande noted, it's standard practice to have <kbd>Esc</kbd> close/cancel a dialog.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload