Defining accelerator keys

You can define an accelerator key for a control to allow users to change focus to the control. An accelerator key is sometimes referred to as a mnemonic access key.

Although it is not standard practice to include accelerator keys in Windows CE applications, you have this capability with applications that you develop in PocketBuilder.

Using accelerator keys with noneditable controls

For noneditable controls, such as a command button or check box, users need only press the accelerator key to change focus to the control and precipitate control events.

StepsTo define an accelerator key for a CommandButton, CheckBox, or RadioButton:

  1. Click the control to display the control’s properties in the Properties view.

  2. In the Text box on the General page, precede the letter that you want to use as the accelerator key with an ampersand character (&).

    When you perform your next action (such as tabbing to the next property, saving the window, or selecting another control in the Layout view), the property is set and PocketBuilder displays an underline to indicate the accelerator key.

    NoteDisplaying an ampersand If you want to display an ampersand character in the text of a control, type a double ampersand. The first ampersand acts as an escape character.

Using accelerator keys with editable controls

You can add accelerator keys to editable controls, but for Pocket PC applications, these are useful only with peripheral keyboards that have an Alt key. Users must press Alt followed by the accelerator key to use an accelerator, and the Alt key is not available on the Soft Input Panel (SIP), or even on some peripheral keyboards, for Pocket PC devices.

StepsTo define an accelerator key for a SingleLineEdit, MultiLineEdit, ListBox, or DropDownListBox:

  1. Click the control to display the control’s properties in the Properties view.

  2. In the General properties page, type the letter of the accelerator key in the Accelerator box.

    For example, if the control contains a user’s name and you want to make Alt+N the accelerator for the control, type n in the Accelerator box.

    At this point you have defined the accelerator key, but the user has no way of knowing it, so you need to label the control.

  3. Place a StaticText control next to the control that was assigned the accelerator key.

  4. Click the StaticText control to display its properties in the Properties view.

  5. In the Text box on the General page, precede the letter that you want to use as the accelerator key with an ampersand character (&).

    For example, if the StaticText control will display the label Name, type &Name in the Text box so that the letter N is underlined. The underlined letter in the StaticText label lets the user know that there is an accelerator key for changing focus to the associated editable control.