Why are accelerators for hidden controls still active?


In the suggestion box, Serge Wautier asked why accelerators for hidden controls remain active. He's apparently rather insistent because he asked the question again a few months later. Asking the same question multiple times reduces the likelihood that I'll answer it. Consider yourself lucky that I wrote this answer before I noticed the duplicate; otherwise I would probably have skipped it.

Why are accelerators for hidden controls still active? Very simple: Keyboard accessibility.

The dialog manager considers controls which indicate that they want characters (DLGC_WANTCHARS) to have no keyboard accelerator. There are a lot of controls that fall into this category, including such popular ones as edit controls, combo boxes, and list boxes. The traditional way of giving these "no accelerator" controls an accelerator is to stick a static control on front of it with the desired accelerator:

    LTEXT           "Ca&pacity:",IDC_STATIC,7,6,31,9
    COMBOBOX        IDC_CAPACITY,7,40,150,300,
                    CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP

But what if you don't want a label to appear in front of the control? For example, the General property page of a file begins with an unlabeled edit control that contains the name of the file. You might have a dialog that contains a list view that you don't want to label because its meaning is implied by other controls on the page or by the page layout.

The answer is to hide the label control but leave it enabled. This keeps the accelerator active, allowing the user to press the accelerator to put focus on the edit control or list view or whatever, but removes the actual accelerator indicator from the screen.

This means that if you want to take a control off the dialog because you don't want the user to invoke it at all, merely hiding it won't be enough, since the accelerator is still active. In addition to hiding the control, you also have to disable it. (Alternatively, you could destroy the control.)

Comments (15)
  1. Tom says:

    So is this posted twice because it was asked twice?  LOL!

  2. GorgeousGeorge says:

    "Asking the same question multiple times reduces the likelihood that I’ll answer it…"

    "If at first you don’t succeed, then quit. There’s no point in being a damn fool about it."

    W. C. Fields.

  3. Dmitry Kolosov says:

    1) If "Ca&pacity:" is hidden, how does the user know to press Alt+P for the combobox?

    2) > the General property page of a file begins with an unlabeled edit control…

    There is  a hidden "File name:" static in front of unlabeled edit, but it does not have an accelerator

  4. mvadu says:

    "if you want to prevent Raymond from posting on some topic you don’t like, just ask him twice and he won’t write about it "

    Ideally.. But today though in the post he mentioned chances of getting an answer by asking the same question are less, indeed he answered twice. So if we follow this approch we might end up getting multiple answers..

  5. Larry Lard says:

    If "Ca&pacity:" is hidden, how does the user know to press Alt+P for the combobox?

    Because the previous n versions of the software had a visible Capacity label, and some users now have "Alt-P gets me to the capacity dropdown" ingrained; the fact that it’s no longer on screen doesn’t help, because people don’t actually read what’s on screen; the fact that the documentation has been updated doesn’t help, because people don’t actually read documentation.

    If Alt-P stopped working, these users would say the latest version was ‘broken’ and hate you.

  6. Bob says:

    Apparantly "hidden" and "disabled" are not synonyms. Who’ld a thunk it?

    Also, the visible control can still have this newfangled thing called a ‘tooltip’ that probably has enough space for a word or two, and even an "(Alt-P)" tacked on at the end to indicate that pressing "alt" and "p" would do something useful. Then people who care can experiment and find out what it does, and people who prefer to use the mouse can ignore it. Its a wonderful system.

  7. Nawak says:

    I’m glad that Raymond didn’t throw this topic away, because I found that quite interesting!

    Thanks Raymond!

  8. Mihai says:

    I tend to use "quick keys" for the underscored characters in dialogs and menus. And call accelerators the more "global" things like Ctrl+S.

    A rule of thumb: an accelerator is stored in an accelerator table.

  9. Neil says:

    I’ve heard the underlined characters referred to as access keys. I agree with accelerators being the name of those shortcut keys that are equivalent to menuitems but without having to open the menu, e.g. Alt+F4 for Close.

  10. Nish says:

    So basically if you want to prevent Raymond from posting on some topic you don’t like, just ask him twice and he won’t write about it *grin*

  11. steveg says:

    Is your GUI disappearing? A worrying trend in UI design. Steveg investigates.

    First accelerator underlines, some as young as 18 pixels,  were wiped off the face of the screen, disappearing without leaving a trace. Police have yet to file charges, hampered by constant rumours of their fleeting reapperance.

    Next in this series of dastardly crimes, entire menus, yes menus, my friends, disappeared off the screen. "Interpol explored every nook and cranny," explained the Inspector in a winsome voice, "but we have found nothing. The missing menu has devestated people across the world."

    Police say they’re looking into ALTernative areas of investigation.

    Next week, Steveg investigates crop circles in Office 14.

  12. The Imp says:

    I’d love to know why someone thought it was a good idea to, in NT5, hide, by default, accelerators until the invocation key (alt) was pressed, but somehow not notice or care that this same key was always also a menu invoker. The end result being, you can’t ever see the accelerators for menus with this (default) setting.

    And you wonder why developers don’t give a damn about things like accessibility?

    [Use the keyboard interface to call up the menu with keyboard shortcuts highlighted. -Raymond]
  13. @The Imp: You hold down alt to show the accelerator hints, and then finish the hotkey by hitting one of the letters indicated

  14. Mihai says:

    Although the underscores are not visible by default in Windows, they are easy enough to enable, and they work as they always did.

    And I think some developers/some companies do care about accessibility.

    I have recently moved to Office 2007. Still puzzled by the UI. At some point I wanted to paste something as text. And I could not find the option. But then I realized this is something I did already several times. Just did not know how.

    Then I have discovered it: the old quick-keys still work. Alt-E (Edit) S (Past Special), and it’s ok. I did it mechanically (muscle memory). Never seen the new option (still no clue how to find it).

    So: ++ for keeping the quick keys working, — for the UI design :-)

Comments are closed.