0

if i have a tedit object (edit1) and a button (button1) on a form and i set the focus to the tedit object, when the application is run, how do i get it to press the button when i press enter while still in the tedit object. i know it's possible, it is widely used in applications, but how do i do it?
thanks

4
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by GoldenEye4ever
0

if i have a tedit object (edit1) and a button (button1) on a form and i set the focus to the tedit object, when the application is run, how do i get it to press the button when i press enter while still in the tedit object. i know it's possible, it is widely used in applications, but how do i do it?
thanks

verify the characters you type in edit, and when enter is pressed the
button1.click();

0

at form design....u must set "hot key"..true..and at editpress...u can add some code like this:

if key=#13 then button1.setfokus

0

if i have a tedit object (edit1) and a button (button1) on a form and i set the focus to the tedit object, when the application is run, how do i get it to press the button when i press enter while still in the tedit object. i know it's possible, it is widely used in applications, but how do i do it?
thanks

In edit1.onKeyPressed(), just use this code:

if ( key = #13 ) then
  begin
    button1.Click();
  end;

The key variable is passed into the onKeyPressed function...thus you need not declare it

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.