I do my validation routine with the Edit Box OnExit event - which works in
every case EXCEPT when the user hits ENTER and fires off the default button.
So, how can I make the OnExit event fire in the case that the user simply
presses ENTER?
Thank you!
write a keydown handler on the edit and when the key = VK_Enter call
the onexit event.
regards
Yannis.
--
"I failed to make the chess team because of my height."
-- Woody Allen
"yannis" <none@noware,non> wrote in message
news:487f...@newsgroups.borland.com...
Dan schrieb:
Hi Dan,
in the onClick event of the button do a TButton(Sender).SetFocus.
That will move the focus to the default button and trigger the onExit of
the last component.
Regards
Gerhard
> If the user uses the TAB key, the OnExit event fires for the Edit Box
> (good).
Because input focus is moving away from the TEdit to the next control in the
tab order.
> If the user CLICKS the DEFAULT button, the OnExit event fires.
Because input focus is moving away from the TEdit to the TButton.
> However, if the user hits the ENTER key, the Default button
> ONCLICK fires without the OnExit firing first.
Because input focus is NOT moving away from the TEdit. The TButton is not
being focused. Pressing ENTER simply calls the OnClick event handler
directly without any window messages involved on the button.
> I do my validation routine with the Edit Box OnExit event
OnExit is not really a good place for that, especially when input focus is
concerned. if Windows is in the process of moving focus to another control,
and you try to force it back to the TEdit, Windows can freak out and weird
behaviors can occur.
> So, how can I make the OnExit event fire in the case
> that the user simply presses ENTER?
You could have the TButton's OnClick handler check if the form's
ActiveControl is still pointing to the TEdit, and if so then perform the
validation.
Gambit