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

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();

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.