
Dialog Controls And Navigation
The various controls in a dialog box respond to tab and
cursor key movement. How the navigation between controls works is sensitive to
the tab stop and group attribute settings associated with the controls.
Sometimes the interaction is not terribly obvious and that’s why we’re going to
have this little talk. Once we are finished with the talk, you’ll make dialog
boxes that are things of simple joy and beauty. Now pay attention. There’s going
to be a pop quiz later.
Organize Control Tab Order
The first thing to pay attention to is tab order. Set your
controls so that they follow a logical order. Users expect that the tab order
starts at the upper left corner, goes off to the right and works its way down to
the bottom. The last things in the tab order are the buttons that close down the
dialog.
As you are no doubt aware, tab order is determined by
viewing a dialog box in Resource View and hitting the Layout\Tab Order command
or simply using the Control D sequence. The default arrangement for a dialog
puts the OK button in the number one slot and the Cancel at number two. This is
just plain wrong and will cause your users to hate and loath you for such
degenerate behavior.
Insert A Control In Tab Order
Here’s an ordering tip that you may be unaware of: let’s
take the situation where you’ve created a true work of art with a billion
controls on it and then you go and add another one somewhere in the middle. How
do you get this new control to merge into the middle of the tab order without
having to go through the entire list from the beginning? Get into tab order mode
(Ctrl D) and shift click on the control that is to precede the newly inserted
control. That tells the resource editor that you want to keep the tab order the
way it is but to jump up in the list to the clicked upon control. The next
control you click on with be inserted into the list in the same manner in which
we are already familiar with.
Group Flag
The purpose of the group flag is to limit the effects of
radio buttons and cursor movement.
Radio Buttons
If you have a set of radio buttons then the first button
gets a group flag and the control that follows that last radio button gets
another group flag. Up and down cursors, once focus goes into the radio group,
will be limited to those controls that are fenced by the controls with the group
attribute.
Push Buttons
Push buttons will also shift focus in reaction to the
cursor keys so you will want to fence them in as well or you’ll end up with
users cursoring into places that they can’t cursor out of. This isn’t a serious
condition, obviously, but it is indicative that someone was a bit sloppy and
will serve to indicate that the person (that would be you, hint hint) who coded
the dialog is a poser who isn’t as sharp as he’d like everyone to believe.
Here’s a real simple example. Let’s say that you have a
listbox as the first control in the tab order and OK and Cancel follow with
their default attributes. All of the controls have Tab Stop checked. When the
dialog starts up, the user can tab to OK. A cursor down will move the focus to
Cancel. Further cursor downs are ignored. Cursor up gets back to OK and another
cursor up shifts focus to the listbox. All cursor up and down keystrokes from
this point on are routed to the listbox which applies them to the currently
selected line.
The fix for this minor annoyance is to check the Group
checkbox in the OK button’s properties.

|