Recent

Author Topic: TEdit enter  (Read 10389 times)

captian jaster

  • Guest
TEdit enter
« on: September 20, 2010, 07:50:40 pm »
How do I set a Tedit so that when ENTER is pressed something is done..

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TEdit enter
« Reply #1 on: September 20, 2010, 08:14:42 pm »
On the OnKeyPress event of the TEdit:

Code: [Select]
if Key = #13 then Do;

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4570
  • I like bugs.
Re: TEdit enter
« Reply #2 on: September 21, 2010, 05:42:49 pm »
Even easier:

Code: [Select]
Edit1.Default := True;

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

mas steindorff

  • Hero Member
  • *****
  • Posts: 554
Re: TEdit enter
« Reply #3 on: September 21, 2010, 06:46:13 pm »
Even easier:

Code: [Select]
Edit1.Default := True;
this is one I've not seen before and I get "no member" error when I try.  can you elaborate?
windows 10 &11, Ubuntu 21+ IDE 3.4 general releases

captian jaster

  • Guest
Re: TEdit enter
« Reply #4 on: September 21, 2010, 07:02:46 pm »
Even easier:

Code: [Select]
Edit1.Default := True;

Juha

Same here...
I also have another question...
I have a TMemo box and a TEdit in my Form..
How can I make so that when the form loads the cursor automatically loads into the TEdit and not the TMemo

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TEdit enter
« Reply #5 on: September 21, 2010, 07:22:58 pm »
Code: [Select]
Form.ActiveControl := Edit;

Or set it on the Object Inspector.

captian jaster

  • Guest
Re: TEdit enter
« Reply #6 on: September 21, 2010, 07:24:04 pm »
Code: [Select]
Form.ActiveControl := Edit;
Thank you ;D

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4570
  • I like bugs.
Re: TEdit enter
« Reply #7 on: September 22, 2010, 12:15:15 am »
this is one I've not seen before and I get "no member" error when I try.  can you elaborate?

Ok, damn. "Default" property belongs to TButton, not TEdit. Sorry. Must have been a short-circuit in my head. Not the first time.
For TEdit you must use OnKeyPress indeed.

"Default" property works well for TButton though. You hit Enter and the button's action is fired.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

krexon

  • Jr. Member
  • **
  • Posts: 80
Re: TEdit enter
« Reply #8 on: September 22, 2010, 09:07:43 am »
Code: [Select]
Form.ActiveControl := Edit;

Or set it on the Object Inspector.

You can also do in that way:
Code: [Select]
edit1.setfocus;
You can replace 'edit1' with combobox, labelededit and so on...

 

TinyPortal © 2005-2018