Accelerator

Applies to

Controls that accept user input, including list boxes, MultiLineEdit, SingleLineEdit, ListView, EditMask, and TreeView

Description

Accelerator keys allow users to select an item (that is, change focus) with a keystroke rather than the mouse. An underlined character in the item’s name or label tells the user what key to press. The user presses it in combination with the Alt key. If the currently selected control is not an editable control (such as a SingleLineEdit, MultiLineEdit, ListBox, or DropDownListBox), you need only press the accelerator key.

Accelerator keys are different from shortcut keys, which are defined key combinations that provide a quick way to accomplish certain tasks.

PowerBuilder term

Windows term

accelerator key

mnemonic access character

shortcut key

shortcut key or accelerator key

Usage


In a painter

StepsTo select a character as an accelerator key

  1. Type the character into the Accelerator box on the General page of the control’s Properties view.

    For example, to set m as the accelerator, type m in the box.

Accelerators for unlabeled controls To show the user what accelerator key to use for an unlabeled control or box, define StaticText to act as a label. Include an ampersand (&) before the character you want underlined. For example, in the StaticText control’s General page, set the Text property to a value like Edit &Maintenance Data for a drop-down list that has m as an accelerator key. If you want an ampersand to display in the text, type two ampersands, and if you want an ampersand to display and serve as the accelerator key, type three ampersands.


In scripts

The Accelerator property is an integer consisting of the ASCII value of the accelerator key. Both of the following lines set m as the accelerator character for a MultiLineEdit control:

mle_1.Accelerator=77

mle_1.Accelerator = ASC("M")