/ Forums / Advansys Formativ / Creating Solutions with Formativ / Dialog box – can I assign hotkeys to buttons?

  • Creator
  • #10199


    Do you happen to have example code of how to add a hotkey to buttons? I would like to take a dialog that I have written, and have it respond when a particular keystroke is hit. For example, if the dialog is just sitting there, and the user hits the escape key, I’d like that to be interpreted the same as if they activated the cancel button on my dialog box. Similarly, I’d like Alt- keys to work: for the OK button, I’d like alt-k to be interpreted the same as if the user had clicked it; and other fields on the dialog box become the focus when an assigned Alt- key was hit.


  • Author
  • #10200


    Thank you for your enquiry. If you designed your dialog in the Form Designer, you can make a button associated with a Hotkey by including an ampersand (&) character prior to the letter you wish to make the hotkey, for example:


    written in the button caption would mean Alt+F is the hotkey. For the OK button, the caption could be O&K and Alt+K is the hotkey.

    You can also set the Modal Result parameter for the button to have the button behave like the standard Windows OK, Cancel, Yes, Abort, Retry and Ignore buttons (mrNone is the default… mr stands for Modal Result, a modal dialog return value which can be tested after the dialog is dismissed to ascertain what type of button was pressed). If you set a button to mrCancel, by default the escape key will dismiss the modal dialog.

    Kind Regards,

    Advansys Support


    Perfect. Thank you very much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.