Recent

Author Topic: Which is the time sequence on this event for a TEdit?  (Read 3653 times)

Elmug

  • Hero Member
  • *****
  • Posts: 849
Which is the time sequence on this event for a TEdit?
« on: August 06, 2011, 03:59:05 am »
Dear Forum people,

I would very much appreciate your most valued help on sharing insight and experience on this issue that now crosses my head:

1. On a TEdit component, there is the event OnEditDone. Some external event must of course establish that the Editing is done.

2. Pressing the Enter key is one such event. Hence pressing the Enter key establishes that OnEditDone fire its procedure.

3. Now, suppose we have Kpreview ON, and OnKeyPressed is firing a procedure that states that if the Enter key is pressed, a Procedure K is to run.

The question is WHICH procedure would fire first, the procedure fired by  OnEditingDone, or the Procedure K?

This question does relate to the manipulation and use of variables set by either or both of the above procedures.

As usual, your kind help is already being thanked-for.

Dick, from the internet

  • Full Member
  • ***
  • Posts: 198
Re: Which is the time sequence on this event for a TEdit?
« Reply #1 on: August 06, 2011, 04:21:13 am »
Try doing a little experimenting;  create a form with a TEdit and a TButton and a global string variable; add the following code:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
  showmessage(s);
  s := '';
end;

procedure TForm1.Edit1EditingDone(Sender: TObject);
begin
  s := s + 'OnEditingDone has fired' + #13#10;
end;

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
  );
begin
  s := s + 'OnKeyDown has fired' +  #13#10;
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: char);
begin
  s := s + 'OnKeyPress has fired' + #13#10;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  s := '';
end;

When you run the program, use the mouse to click into TEdit and press Enter; then click the button to show a message dialog with something like the following:

OnKeyDown has fired
OnKeyPress has fired
OnEditingDone has fired
OnEditingDone has fired

So, on my system, KeyDown fires first, then KeyPress, and lastly EditingDone.  This is not foolproof, but you should get the idea.  Try this with all of the different events for each control and get an understanding how the events synchronize under different conditions.

  geno.


Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Which is the time sequence on this event for a TEdit?
« Reply #2 on: August 06, 2011, 05:42:46 am »
Smart suggestion, Geno.

I will try as you say. Maybe  I might even have them write the time just in case the difference is detectable.

Also, though I suppose that one procedure is completed before the next one takes place, doesn't it?

Even if the system has more than one processor, all of these events take place one after the other, don't they?

Thanks!


 

TinyPortal © 2005-2018