Var d As New MessageDialog // declare the MessageDialog object
Var b As MessageDialogButton // for handling the result
d.IconType = MessageDialog.IconTypes.Caution // display warning icon
d.ActionButton.Caption = "Save"
d.CancelButton.Visible = True // show the Cancel button
d.AlternateActionButton.Visible = True // show the "Don't Save" button
d.AlternateActionButton.Caption = "Don't Save"
d.Message = "Use TAB to navigated to the button and press enter."
d.Explanation = "Though the correct button is highlited " + Chr(13) + Chr(10) + _
"The default button is the one that fires. "
b = d.ShowModal // display the dialog
Select Case b // determine which button was pressed.
Case d.ActionButton
// user pressed Save
MessageBox("user pressed save")
Case d.AlternateActionButton
// user pressed Don't Save
MessageBox("user pressed Don't save")
Case d.CancelButton
// user pressed Cancel
MessageBox("user pressed cancel")
End Select
Hmmm… ok. BUT the rest of the gui already responds to the TAB and ENTER keys. So I’m wondering if there is a way to make the dialog box accept the ENTER key for the button that is high-lighted?
Many applications have dialogbox when we quit asking if we want to save or not the modified documents.
In the example below (Xojo), which key should I hit in order to not save?
Enter=Return is the “Save” button, Esc the “Cancel” button, but “Don’t save”?
I hit spacebar, Tab or arrows keys but I only get a beep.
It is a Off-topic question as it apply to all Mac applications but as this thread was about the same subject….
That’s because you have ‘Keyboard navigation’ turned off (OS setting). If you turn that on then you can use other keys to move between buttons and activate the buttons (will add a focus ring to the corresponding button).
Cmd-D only works on apps that use this “Don’t Save” phrasing. Apps that use the new Save / Delete dialog, the shortcut was changed to Cmd-Backspace to annoy every long time Mac user who’s been hitting Cmd-D for 20+ years.
Thank you Tim, effectively when I create a new TextEdit document just to paste some temporary text and close the window, the button was not “Don’t save” but “Delete” and I was searching too the short-key, but I need it less often then I didn’t ask for that. You gave me the answer, I will try to remember it too.
That’s because TextEdit supports automatic save and versioning. These are saved each time they are changed. Thus “Don’t save” doesn’t make sense as it is already saved. The choice becomes update it or delete what has been saved already.