Defining accelerator keys
You can define accelerator keys for controls to allow users
to change focus from one control to another. An accelerator key
is sometimes referred to as a mnemonic access key.
Users press Alt followed by the accelerator key to use an
accelerator. If the currently selected control is not an editable
control (such as a SingleLineEdit, MultiLineEdit, ListBox, or DropDownListBox),
users only have to press the accelerator key. They do not need to
press the Alt key.
How you define accelerator keys depends on whether the type
of control has displayed text associated with it. If
there is no displayed text, you must define the accelerator key
in the control itself and in a label that identifies the control.
To define an accelerator key for a CommandButton,
CheckBox, or RadioButton:
-
Click the control to display the control’s
properties in the Properties view. -
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 tab to the next
property or select the window or a control in the Layout view),
the property is set and PowerBuilder displays an underline to indicate
the accelerator key.Displaying 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.
To define an accelerator key for a SingleLineEdit,
MultiLineEdit, ListBox, or DropDownListBox:
-
Click the control to display the control’s
properties in the Properties view. -
In the General tab 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. -
Place a StaticText control next to the control
that was assigned the accelerator key. -
Click the StaticText control to display its properties
in the Properties view. -
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. Now your user knows
that there is an accelerator key associated with the control.