none
WPF access keys - why do they work without the ALT key RRS feed

  • Question

  • Hi!

    We just recognized that if we place a checkbox on our window with its content set to "_Test" we can not only check or uncheck that box by pressing ALT+T but also by pressing T only. I searched the web and everywhere people state you have to press ALT+<key> but it seems like that is not correct for WPF.

    If anyone has information on this or maybe even knows how to enforce pressing ALT+<key> it would help a lot.


    Tuesday, December 9, 2008 10:01 AM

Answers

  • This is the way mnemonics are supposed to work, and the behaviour is the same in windows forms. If the focus is on an element that doesn't actually accept keystrokes itself (textboxes do, buttons don't) the alt key is optional when triggering a mnemonic on another control on the window.
    Controls for WPF and Windows Forms at http://www.divelements.co.uk
    • Marked as answer by Simbalight Thursday, December 11, 2008 8:01 AM
    Tuesday, December 9, 2008 3:11 PM

All replies

  • This is the way mnemonics are supposed to work, and the behaviour is the same in windows forms. If the focus is on an element that doesn't actually accept keystrokes itself (textboxes do, buttons don't) the alt key is optional when triggering a mnemonic on another control on the window.
    Controls for WPF and Windows Forms at http://www.divelements.co.uk
    • Marked as answer by Simbalight Thursday, December 11, 2008 8:01 AM
    Tuesday, December 9, 2008 3:11 PM
  • Thank you! You are right. I did not recognize that until now. I know that back in the times of VB6 the ALT key was obligatory and still took that for granted. It also explains why sometimes "strange" things happen when typing while not recognizing that the input element hasn't got focus. I will avoid mnemonics outside of menus now (In fact Microsoft recomments that in documentation).
    Thursday, December 11, 2008 8:01 AM