[DUG] Edit box exit event

John Bird johnkbird at paradise.net.nz
Wed Jan 25 12:04:03 NZDT 2006


This works fine, (I don't know if there is a better way)

The only event that fires before the Tedit exit event I have found so far is
the MouseEnter event of the other control.
So - I added a variable called DoOtherStuff and used this event to disable
the Tedit exit event if it is set.  And I set this variable if the user puts
the mouse over any components I want to allow an immediate jump to...


procedure TfrmAboutTRun.btnSetupMouseEnter(Sender: TObject);
begin
  DoOtherStuff:=true;
end;

procedure TfrmAboutTRun.btnSetupMouseLeave(Sender: TObject);
begin
  DoOtherStuff:=False;
end;

And on the Tedit Exit event:

procedure TfrmAboutTRun.edtJobExit(Sender: TObject);
var
tempstr:string;
begin
  if DoOtherStuff=true then exit;
	.......normal Tedit checking code in here...
End;

John

-----Original Message-----
From: Bevan Edwards [mailto:bevan at achieve.co.nz] 
Sent: Wednesday, 25 January 2006 9:53 a.m.
To: johnkbird at paradise.net.nz; NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Edit box exit event


Hi John,

I don't know about elegant, and it's been a while since I last did 
something like this, but I used to have a variable in the form class 
called bSystem (boolean, of course).

In the OnExit event I check if this is true, and then just return if it is.

Then anywhere that I don't want the event to "execute", I just set 
bSystem to true before I do anything else.

Remember to reset it to false again afterwards though! ;)

Regards,

Bevan


John Bird wrote:
> On an edit box (TEdit), in the exit event I often will have some 
> verification code for any alteration made to the text.
> 
> However sometimes I don't want it to fire, for example if elsewhere on 
> the form is an unrelated button eg "Setup Options" and the user clicks 
> there in this case I just want focus to go to the other control, 
> without firing the exit event.  (I don't mind losing the contents or 
> the checking of the Tedit in this case, as the user has elected to do 
> something unrelated).  However the exit event on the Tedit fires 
> before any event code on the Tbutton (Setup Options) fires.
> 
> It seems to me to require code in the Tedit exit event checking how 
> the exit has been fired...whether by Tab key, or by clicking 
> elsewhere.  But this gets quite tedious if there is a screen of 
> Tedits.  And it has to be smart - if the user has just clicked on the 
> next Tedit field, in that case I would want the exit event on the 
> previous one to still fire.
> 
> How do others do this - is there an elegant way?
> 
> John
> 
> 
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
> 





More information about the Delphi mailing list