whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

38 Visitors Online


 
...assign multiple or not pre defined shortcuts with a TAction at runtime?
Autor: Loïs Bégué
Homepage: http://www.arpoon.com
[ Print tip ]  

Tip Rating (8):  
     


{++++++++++++++++++++++ Deutsch ++++++++++++++++++++++++++++++++++++++++++++
Sie können ein TActionList bzw. TAction benutzen, um verschiedene Shortcuts
einem Menüpunkt oder einem Button zuzuordnen.
Ebenfalls nutzen Sie diesen Tip, um "nicht registrierte" Shortcuts zu nutzen.
Beipiele für nicht registrierte Shortcuts:
[Numpad 1]..[Numpad 0]
[CTRL] + [SHIFT] + [+]
...
+++++++++++++++++++++++ English ++++++++++++++++++++++++++++++++++++++++++++
You can use a TActionList/TAction to manage with more than one shortcut,
giving your Buttons, Menuitems... more flexibility.
You can also register "extended" shortcuts, wich are not in defined in the
standard shortcut list.
+++++++++++++++++++++++ Français++++++++++++++++++++++++++++++++++++++++++++
Vous pouvez définir des raccourcis multiples pour une action, un menu, un
bouton etc...
De plus, vous pouvez définir de nouveaux raccourcis (non définis par défaut
dans les fichiers de Delphi)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

uses Menus;

procedure TMyForm.AddShortcut(Action: TAction; strShortcut: string;
Key: Word; Shift: TShiftState);
begin
if
Assigned(Action) then with Action.SecondaryShortCuts do
AddObject(strShortcut, TObject(Menus.ShortCut(Key, Shift)));
end;


procedure TMyForm.FormCreate(Sender: TObject);
begin
// you may define the shortcut string at will.
// for some keys on your keyboard, you'll have to look for
// the "real" keycode (use f.e FormKeyDown to retrieve
// the value :)
// Some keys are defined in the Windows unit. Look for "VK_xxxxx".
AddShortcut(MyAction1, 'CTRL+Numpad1', VK_Numpad1, [ssCTRL]);
AddShortcut(MyAction1, 'CTRL+SHIFT++', 187, [ssCTRL, ssSHIFT]);
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners