RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
THotKey.Modifiers Property

Specifies the key or keys that are used in combination with a non-modifier key.

Pascal
property Modifiers: THKModifiers;
C++
__property THKModifiers Modifiers;

Use Modifiers to select a modifier key such as Ctrl, Alt, or Shift for the hot key. These are the possible values:

Value 
Meaning 
hkShift  
The Shift key is used as a modifier.  
hkCtrl  
The Ctrl key is used as a modifier.  
hkAlt  
The Alt key is used as a modifier.  
hkExt  
The Extra key is used as a modifier.  

The default value is hkAlt.  

Modifier keys are used with other non-modifier keys such as character and function keys, arrow keys, and so on. More than one modifier key can be used.  

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!