How can I dismiss dialog in Cocoa application when user presses Esc or Enter key? I have OK button, is it possible to make it default button?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you present the alert panel using the
NSAlertclass or,NSRunAlertPanelfamily of functions, or theNSBeginAlertSheetfamily of functions, you will get support for default and cancel buttons automatically.If you’re presenting a sheet that needs OK/Cancel buttons, and you’re not using any of the above, you should be able to assign your buttons appropriate keyboard equivalents in Interface Builder using the attributes inspector. (Just highlight the Key Equiv. area and press the key you want to be equivalent to pressing that button.)
If you’re presenting a dialog that’s not either an alert or a document/window-modal sheet — don’t. 🙂 Document-modal alerts aren’t Mac-like, and shouldn’t be used for things like preferences windows.