Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread KeyDown event hangs on ENTER key
Thu, May 29 2014 3:34 PMPermanent Link

Sergei Safar

Hi,

please, try this:

New Visual Project
Drop a TEdit
Drop a TButton and write something on Button1Click event like: ShowMessage('Hello');
Write on Edit1KeyDown event:

begin
 Result := true;
 if (Key = 13) then begin
    Button1Click(nil);
    Result := false;
 end;
end;

Run the app (F9)
Click inside Edit1 and press ENTER:

Nothing happens or sometimes the IDE hangs. Other Key values like 8 (backspace) or 9 (TAB) works perfectly.

-
Sergei Safar
Thu, May 29 2014 5:14 PMPermanent Link

Walter Matte

Tactical Business Corporation


Did you set:

Form1.KeyPreview := True;   // this must be set to True


I don't see it hanging... works as expected.

Walter
Fri, May 30 2014 3:10 AMPermanent Link

Matthew Jones

Sergei Safar wrote:

> Nothing happens or sometimes the IDE hangs. Other Key values like 8

Most likely this is an infinite loop. Check you haven't put it in the
buttonclick routine too.

--

Matthew Jones
Fri, May 30 2014 6:44 AMPermanent Link

Uli Becker

Sergei,

> Nothing happens or sometimes the IDE hangs. Other Key values like 8
(backspace) or 9 (TAB) works perfectly.

There were some discussions of similar issues.
Have a look here e.g.:

http://tinyurl.com/kdtskr9

Uli
Fri, May 30 2014 9:27 AMPermanent Link

Sergei Safar

Walter,

>>Form1.KeyPreview := True;   // this must be set to True

KeyPreview = true solved the problem.

Thank you all for the replies

Example here:
http://www.shs.eng.br/test/project23.html

--
Sergei Safar
Image