Re: handling focusLost Events

From: Chris (chris2k01_at_hotmail.com)
Date: 10/25/03


Date: Sat, 25 Oct 2003 06:25:15 GMT


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nuggy wrote:

> I also want to NOT perform the focus lost validation if the user
> clicks a "clear" button that clears out all the data on the screen.
> It won't let the user do this because when you click the button it
> validates the field you were in, and if it's not valid you get the
> dialog popup.

Hello,
I think this part is probably the hardest. Try to consider people
using the keyboard to navigate your program: when they want to get to
the clear button, they have to Tab through all the other fields to
get there. This means they have to validate, just for the user to get
to the clear button. Personally, I would consider just putting a
little marker, which should be fairly non-intrusive, beside each
field. If it invalidates, put a short message (maybe written in red
text or something) that says so. Finally, as long as one or more
fields are invalid, disable the submission button! The user can't go
any further until the fields are valid, and they know which ones are
valid and which aren't. I think this is a much friendlier way of
accomplishing the same result, especially to keyboard users.

If you REALLY want to do this, though, what you'd need to investigate
is the use of FocusEvent.getOppositeComponent(). It'll tell you what
component focus is moving to, in the case of a lost focus event. For
your mouse users, that'll allow them to click the Clear button. For
your keyboard users, well, hopefully the first element in the window
is the first field of the form, and the last element in the window is
the Clear button. That way, assuming they're smart enough, they
should be able to Shift+Tab backwards through form fields that are
already valid, until they wrap around backwards and get to the Clear
button.

- --
Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/mbTfwxczzJRavJYRAmZgAKCafWUXTQyQ7xeN/MVSdKM+qbiuswCeISfr
OhiYvqJ+eHo5bsKbYvl4muE=
=QWpQ
-----END PGP SIGNATURE-----


Quantcast