Creates a menu shortcut for a specified key combination.
function ShortCut(Key: Word; Shift: TShiftState): TShortCut;
TShortCut ShortCut(Word Key, TShiftState Shift);
Call ShortCut to create a menu shortcut at runtime.
Specify a Key value using a virtual key code (Menus version) or Qt key code (QMenus version).
Specify the values for the Shift, Control, and Alt keys by using a set of type TShiftState. For example, to specify the Shift key, use the set [ssShift]. To specify a Shift and Ctrl key combination, use the set [ssShift, ssCtrl].
Assign the value returned by ShortCut as the value of the ShortCut property of a menu item.
C++ Examples:
/* This example creates a shortcut, Ctrl+O, at run time and assigns it to the Open command on a File menu. */ void __fastcall TForm1::OpenCommandClick(TObject *Sender) { MessageDlg( "The Open command has been selected.", mtInformation, TMsgDlgButtons() << mbOK, 0); } void __fastcall TForm1::FormCreate(TObject *Sender) { OpenCommand->ShortCut = ShortCut(Word('O'), TShiftState() << ssCtrl); }
Delphi Examples:
{ This example creates a shortcut, Ctrl+O, at run time and assigns it to the Open command on a File menu. } procedure TForm1.FormCreate(Sender: TObject); begin OpenCommand.ShortCut := Menus.ShortCut(Word('O'), [ssCtrl]); end; procedure TForm1.OpenCommandClick(Sender: TObject); begin MessageDlg('The Open command has been selected.', mtInformation, [mbOk], 0); end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|