Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

Short Keys

In My apllication i would like to invoke the mouse click events from the keyboard through different short keys
ie to assign different onclick events of controls to keyboard also with shifting the focus to it
whats the best way of doing this
with regards
tct
0
palabros
Asked:
palabros
  • 4
  • 2
1 Solution
 
geobulCommented:
Hi,
Drop a TActionList component on your form, double-click on it to open the actions editor, add few actions, assign ShortCuts (ShortCut property) to them and write appropriate OnExecute events.

Regards, Geo
0
 
geobulCommented:
Example:

type
  TForm1 = class(TForm)
    ActionList1: TActionList;
    Action1: TAction;
    Edit1: TEdit;
    Memo1: TMemo;
    Button1: TButton;
    procedure Action1Execute(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Action1Execute(Sender: TObject);
begin
  Button1.SetFocus;
  Button1Click(Sender);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage('Button1 was pressed');
end;
0
 
palabrosAuthor Commented:
i think my question is not clear.
i have an apllication in which there some buttons ,doubleclick events on grid etc . i would like to invoke these events on keyboard shortkeys like shift+v or something of that sort
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
geobulCommented:
That's what I'm talking about. In my example above there are some controls on a form and Button1 is one of them. It has its own OnClick event named Button1Click. Action1 from ActionList1 has ShortCut property set to Ctrl-V and OnExecute event which changes the focus to Button1 and fires its OnClick event. It doesn't matter where the focus currently is. It can be on a memo or edit control.

Shift-V is an alphanumeric key (capital v for example) and therefore can't be used as a shortkey.

Regards, Geo
0
 
palabrosAuthor Commented:
Thanks a lot. it worked fine
0
 
geobulCommented:
You're welcome. I'm glad that it helped you :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now