A user of mine just mentioned to me that there are standard OS X shortcut keys that go with the usual dialog window that asks the user if they want to save unsaved changes before closing.
Example: The dialog offers “Don’t Save”, “Cancel”, and “Save”
The keyboard shortcut for “Don’t Save” is Cmd+Delete
The keyboard shortcut for “Cancel” is Escape
The keyboard shortcut for “Save” is Enter or Cmd+S
I knew about Cancel and Enter, but I’ve never heard of the others.
I normally use a MessageDialog for this, but I don’t see any way to implement Cmd+Delete and Cmd+S using it.
Is there a way using Message Dialog? Or do I need to build a custom modal dialog window with a timer to do this?
Do you want to save the changes you made in [...] ? < this line in bold
Your changes will be lost if you don't save them. < this line in regular
[ Don't Save ] [ Cancel ] [ Save ]
Keyboard shortcuts (in parentheses are the explanation from the HI Guidelines):
Don’t Save: Cmd-Delete (Selects Don’t Save in dialogs that contain a Delete or Don’t Save button, replaces Command+D)
Cancel: Esc (Click the Cancel button) and maybe Cmd-Period (used to be listed in the HI Guidelines, but now not anymore)
Save: Enter and Return (Save the active document)
Cmd-S is for the form where you edit the data. It omits the dialog box and directly saves the changes.
[code]declare sub setKey lib “Cocoa” selector “setKeyEquivalent:” (id As integer, key As CFStringRef)
declare sub setMod lib “Cocoa” selector “setKeyEquivalentModifierMask:” (id As integer, mask As UInt32)
dim cntrlKey As UInt32 = Bitwise.ShiftLeft(1, 18)
dim optnKey As UInt32 = Bitwise.ShiftLeft(1, 19)
dim cmdKey As UInt32 = Bitwise.ShiftLeft(1, 20)
There must be something more though because this sets only one key trigger yet testing in TextEdit it works as Eli said, ie some with 2 key equivalents.
Also, setting the key equivalent to Chr(13) (for return) makes a PushButton blue (default OS behavior). But if you set the button as ‘Default’ in Xojo and set the key equivalent to Command-S then the button is not blue yet it’ll respond to both Command-S and Return. I don’t know what’s happening there, how multiple key equivalents happen, if that’s what’s going on.
Only recent change are the new use of cmd-D that opens the Desktop folder. Thank you for giving the new value: cmd-delete !
[this worked fine on TextEdit and Preview (Apples applications), I suppose it works everywhere).
The only problem (in the modern years) is the lack of an Apple Users Manual that tells us what we need to know.
I even was unable to ket the Whats New in OS X pdf document (for Mavericks and Yosemite) that had valuable informations.
BTW: John (and everyone including me), can you think to add the OS version when you have questions ? This allows to send a better answer.
Talking about news on recent MacBook Pro (the one I have is Mid 2014) pressing the Option Key at boot time does not goes into the Recovery partition.
Instead, use cmd-Shift-R and thanks the genius at Strasbourg Apple Store who gives this tip to another genius (and I ‘recorded’ it).
On the other hand, if you want to boot on an external boot hard disk Recovery (or standard) partition, continue to use the Option Key (alt) at boot time.
As it happens, the app the user was asking about was written in 2009 and is maintained with RS2011R3 because it’s still a universal build. The new version of the app will be using Xojo 2015 and will be strictly Intel-only, I’ll be updating the shortcut keys for the Xojo build but not the now-antique 2009 version.