Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to force an ONEXIT Event from an Edit Box?

1,239 views
Skip to first unread message

Dan

unread,
Jul 17, 2008, 10:31:51 AM7/17/08
to
Overview: The user enters a date into an regular edit box. If the user
uses the TAB key, the OnExit event fires for the Edit Box (good). If the
user CLICKS the DEFAULT button, the OnExit event fires. However, if the
user hits the ENTER key, the Default button ONCLICK fires without the OnExit
firing first.

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!


yannis

unread,
Jul 17, 2008, 11:40:26 AM7/17/08
to
Dan wrote:

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

Dan

unread,
Jul 17, 2008, 11:46:58 AM7/17/08
to
Thank you!


"yannis" <none@noware,non> wrote in message
news:487f...@newsgroups.borland.com...

Gerhard Zampich

unread,
Jul 17, 2008, 1:11:05 PM7/17/08
to

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


Remy Lebeau (TeamB)

unread,
Jul 17, 2008, 3:40:34 PM7/17/08
to

"Dan" <hid...@hotmail.c0m> wrote in message
news:487f5905$1...@newsgroups.borland.com...

> 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

0 new messages