Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't my form's OnKeyDown event handler fire?

I'm using Delphi 2009 and I followed a tutorial at delphi.about.com, but I couldn't set it.

I created an event OnKeyPress/OnkeyDown and set a breakpoint to see if the event is called, but it's not being called in any way.

Where is the problem?

EDIT:

procedure TFormMain.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  Beep; //breakpoint is set here.
end;
like image 348
Ivan Prodanov Avatar asked Nov 27 '22 23:11

Ivan Prodanov


1 Answers

You might try to set

Form1.KeyPreview := True;

Maybe the event is not properly delegated up to the form.

EDIT: after looking at the link I guess you probably have done that since it is mentioned in the article. Maybe you forgot that line?

like image 126
jpfollenius Avatar answered Jan 11 '23 03:01

jpfollenius