Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the accelerator hot key '&' character?

I'm using the '&' character for using accelerator keys with my TLabel controls. In this way, the user can press Alt+Character after the & in order to focus controls on the form.

Example:

var
  MyLabel : TLabel;
  MyEdit : TEdit;
begin
  MyEdit := TEdit.Create(Self);
  MyEdit.Left := 20;
  MyEdit.Top := 40;
  MyEdit.Parent := Self;

  MyLabel := TLabel.Create(Self);
  MyLabel.FocusControl := MyEdit;
  MyLabel.Caption := '&Test';
  MyLabel.Left := 20;
  MyLabel.Top := 20;
  MyLabel.Parent := Self;
end;

In this case, MyLabel appears with the 'T' character underlined and pressing Alt+T causes MyEdit to be focused.

enter image description here

How can I get MyLabel.Caption without the '&' character? Is there any built in function for doing this?

I'm expecting to get 'Test' string instead of '&Test'

like image 803
Fabrizio Avatar asked May 17 '18 15:05

Fabrizio


1 Answers

You are looking for the StripHotKey function.

like image 156
David Heffernan Avatar answered Oct 22 '22 13:10

David Heffernan