Avoid closing of the window when user hits cmd+w keys.

Discussion in 'Mac Apps and Mac App Store' started by mycompuser, May 11, 2015.

  1. mycompuser macrumors member

    Joined:
    May 8, 2012
    #1
    Hi All,

    I am developing an mac application. And in one of the use cases, I prompt for an window with an OK button. I want the user to respond to the OK button on the window to close the window.
    I have unchecked the "Close" option in the xib which disables the close option in the UI.

    But if the user were to hit "Command + w" key when the window has focus, the window closes.
    Is there a way by which I can ignore this command so that the window remains opened?

    Tried implementing "windowShouldClose" delegate method, but found that this method does not get called at all. The documentation too says that this method is not reliable.
     
  2. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #2
    Hi

    You might get a better response by posting this in the Mac Programming section.

    I'm no expert, but assuming your window is a normal NSPanel or NSWindow then you just need to deselect "Close" as shown in the screenshot.
     

    Attached Files:

Share This Page