RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
THotKey.HotKey Property

Contains the current key combination of the accelerator key control.

Pascal
property HotKey: TShortCut;
C++
__property TShortCut HotKey;

Use HotKey to set or change the key combination associated with the accelerator key. Alt+A is the default. To modify the value of HotKey either edit it directly or set the value of the Modifiers property. At runtime, HotKey is reset when the accelerator key has focus and the user presses valid key combinations.  

C++ Examples: 

 

/*
To use this example, create a form with a main menu 
component and a HotKey component.  At design time, use the 
Menu designer to add menu items, including a "File" menu 
with subitems that includes a "New" menu item.  Add the 
following code to the OnCreate method of the form and the 
OnClick event of the File menu item.
*/
void __fastcall TForm1::File1Click(TObject *Sender)
{
  // Assign HotKey to the menu's File "New" item. 
  New1->ShortCut = HotKey1->HotKey;
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  // Default to "Ctrl + A"
  HotKey1->Modifiers.Clear();
  HotKey1->Modifiers << hkCtrl;
  // Don't allow shift or alt
  HotKey1->InvalidKeys.Clear();
  (HotKey1->InvalidKeys << hcShift) << hcAlt;
//  HotKey1->Visible = false;
}

 

Delphi Examples: 

{
To use this example, create a form with a main menu 
component and a HotKey component.  At design time, use the 
Menu designer to add menu items, including a "File" menu 
with subitems that includes a "New" menu item.  Add the 
following code to the OnCreate method of the form and the 
OnClick event of the File menu item.
}
procedure TForm1.File1Click(Sender: TObject);
begin
  // Assign hotkey to the menu's File "New" item. 
  New1.ShortCut := HotKey1.HotKey;  
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Default to "Ctrl + A"
  HotKey1.Modifiers := [hkCtrl];
  // Don't allow shift or alt
  HotKey1.InvalidKeys := [hcShift, hcAlt];
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!