Gentle reminder: On a dialog box, do not give OK and Cancel accelerators

Raymond Chen

I know most of you know this, but I’m going to say it for the record. When you have a dialog box with an OK and/or Cancel button, do not give the keys accelerators. In other words, simply write

    PUSHBUTTON "Cancel", IDCANCEL, ...

The dialog manager already has those buttons covered. The hotkey for the OK button is Enter (since it is the default pushbutton), and the hotkey for the Cancel button is ESC (since its ID is IDCANCEL).

Note of course that during the lifetime of a dialog box, the default pushbutton may change, but the principle still stands: Do not give the OK button a keyboard accelerator.

Oh, and while you’re there, don’t forget that the recommended minimum size for pushbuttons is 50dlu by 14dlu.


Discussion is closed.

Feedback usabilla icon