MakeShortcut(Modifiers: KeyModifiers; Key: Keys);
Modifiers - modifier of the additional keys that should be used in combination. The appropriate value with Or separator should be set to use several additional keys.
Key - key that should be used as the hot key.
The MakeShortcut property returns the value that corresponds to the combination of hot keys that should be assigned for any action.
Executing the example requires a form, a button named Button1 on it, the ActionList component named ActionList1 and the MainMenu component named MainMenu1. The code also contains the OnSelectAll procedure, which signature corresponds to the signature of the method that implements the OnExecute event of the ActionItem action.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
AItem: ActionItem;
MItem: IMenuItem;
Begin
AItem := New ActionItem.Create;
AItem.ActionList := ActionList1;
AItem.Caption := "Select all";
AItem.Hint := "Selection of all objects";
AItem.ShortCut := Self.MakeShortcut(KeyModifiers.Ctrl Or KeyModifiers.Shift, Keys.A);
AItem.OnExecute := OnSelectAll;
MItem := New MenuItem.Create;
MItem.Action := AItem;
MainMenu1.Items.Add(MItem);
End Sub Button1OnClick;
After executing the example clicking the button creates a new action for the ActionList component. The header of new action is "Select all", the OnSelectAll custom procedure is called when the action is executed. SHIFT+CTRL+A combination of hot keys is available for calling the action. A new menu item is created for the MenuItem component. This menu item is connected with the created action.
See also: