Subject RES: [IBO] OnValidateFields behavior
Author Claudio Kloss
Jason,

I think that what the user would expect after receiving an exception telling
him that the value wasn't correct is stay at the control for letting him to
change the data.

After looking into the source code (not so deeply). I guessed that adding
"FocusControl" would do what I wanted.

About the grid, I don't now if this approach will work in any case. If you
want I could check this.

And I guess there is another glitch. What the user has typed is being lost.
I think the user would expect to see the wrong value he typed and be allowed
to retype or use <Ctrl> <Z> to undo the change. Maybe we have to remove that
Move in the Except block.


Claudio F. Kloss
MicroLight Informática Ltda.
Juiz de Fora - MG - Brazil

-----Mensagem original-----
De: Jason Wharton [mailto:jwharton@...]
Enviada em: sexta-feira, 16 de março de 2001 22:48
Para: IBObjects@yahoogroups.com
Assunto: Re: [IBO] OnValidateFields behavior

Doesn't the exception prevent them from leaving the control?

What if they were in the grid and it happens to move the focus to another
control?

What do others think of this suggestion?

Thanks,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com


----- Original Message -----
From: "Claudio Kloss" <ckloss@...>
To: "IBObjects" <IBObjects@yahoogroups.com>
Sent: Thursday, February 22, 2001 1:35 PM
Subject: [IBO] OnValidateFields behavior


> Jason,
>
> When an exception is raised in OnValidateField after the user has pressed
> <Tab>, focus is being passed to the next control and the edit control that
> raised the exception displays the wrong value. If I <Shift><Tab>, the
value
> is displayed correctly.
>
> What do you think of calling "FocusControl" in the except block in
> "SysAfterModify"? This way locking the focus on the control that raised
the
> exception on the same way when we have required fields left null.
>
> I think the users would expect this behavior.
>
>
> procedure TIB_Column.SysAfterModify;
> begin
> if not FValidating then
> try
> FValidating := true;
> try
> if Assigned( FOnValidate ) then
> FOnValidate( Self );
> with Statement do
> if Assigned( FOnValidateField ) then
> FOnValidateField( Statement, Row, Self );
> except
> Move( FValidateBuffer^, FNewColumnInd^, DataSize +
> SizeOf(smallint));
> FocusControl; // Line included
> raise;
> end;
> finally
> FValidating := false;
> end;
> FRow.SysAfterColumnModify( Self );
> if SysInternalChanged then
> DoAfterModify;
> end;
>
> Claudio F. Kloss
> MicroLight Informática Ltda.
> Juiz de Fora - MG - Brazil