Hi,
I'm developing a VID form, and I can't figure out the behavior of fields when I
enter data and press the TAB or ENTER keys to proceed to the next field. I want
to validate the entered value, and if it's invalid, display an alert and then
keep the focus on the invalid field so it may be corrected. The code below
works that way (sort of) when the ENTER key is pressed in the first field, but
if the TAB key is pressed instead, the focus advances to the next field,
overriding my focus command.
Here's the code I'm testing with:
Rebol []
form: layout [
f1: field "Enter some text" [
if f1/text <> "A correct value" [
alert "Please enter a correct value in this field."
focus f1 ;Works if ENTER pressed; not if TAB pressed
]
]
f2: field "Enter any text"
]
focus f1 ; Start with cursor in first field
view form
When TAB is pressed in the first field, the "focus f1" line is either ignored
or overridden, and the focus ends up in the second field. If ENTER is pressed,
the focus goes to the second field while the alert box is displayed, but
returns to the first field when it is dismissed.
What I really want is for the focus to remain on the first field whichever key
is pressed on an incorrect entry. It seems like it should be really simple to
do this, but I haven't come up with anything yet. Can anyone offer a suggestion?
TIA,
Bernie Schneider
The individual has always had to struggle to keep from being overwhelmed
by the tribe. To be your own man is a hard business. If you try it, you will
be lonely often and sometimes frightened. But no price is too high to pay
for the privilege of owning yourself.
--
Friedrich Nietzsche --
-- Attached file included as plaintext by Ecartis --
-- Desc: "AVG certification"
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.9.2/55 - Release Date: 7/21/2005
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.