Reputation: 451
I'm using Lazarus 1.2.6 on OS X Yosemite, and my problem is, tha when I disabled TabStop
in every object, and I wrote a pretty little code for that myself( because of need of circular tab-ing) , but using #9(tab) it won't work. Does work with any other key.
procedure TForm1.ListBox1KeyPress(Sender: TObject; var Key: char);
begin
if Key = #9 then
form1.ActiveControl:=button4;
end;
Upvotes: 0
Views: 254
Reputation: 494
Your problem is caused by the fact that OnKeyPress
only handles printable ASCII chars. In order to handle non-printable symbols like the tabulator key you should use the OnKeyDown
event.
Your handler could look like:
procedure TForm1.ListBox1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_TAB then
form1.ActiveControl := button4;
end;
In order to access VK_TAB
you should add LCLType
to your uses clause. Of course this procedure should be defined as the handler of the OnKeyDown
event of your controls or your form.
See http://wiki.lazarus.freepascal.org/LCL_Key_Handling and http://lazarus-ccr.sourceforge.net/docs/lcl/lcltype/index-2.html for reference.
Upvotes: 1