Hi ,
Is it possible to know what caused a focus lost event? A user that presses
TAB (caused by keyboard) or a use clicks on another component with the mouse
(caused by mouse). I need to distinguish between these two.
Thanks,
--
Tom Tempelaere
Please remove _N_OSPAM from the front
and MAPSO_N_ from the back of my
e-mail address. Sorry about this.
|
|
0
|
|
|
|
Reply
|
TT
|
9/25/2003 10:17:48 AM |
|
In article <ghzcb.39479$sM2.1863742@phobos.telenet-ops.be>,
"TT \(Tom Tempelaere\)" <_N_OSPAMtiti____@hotmail.comMAPSO_N_> wrote:
>:Hi ,
>:
>:Is it possible to know what caused a focus lost event? A user that presses
>:TAB (caused by keyboard) or a use clicks on another component with the mouse
>:(caused by mouse). I need to distinguish between these two.
>:
>:Thanks,
I haven't tried this, so it's guesswork. But in the FocusEvent received
by the focusLost method, you can check the source of the event. It may
be possible to tell from the source what triggered the loss of focus.
= Steve =
--
Steve W. Jackson
Montgomery, Alabama
|
|
0
|
|
|
|
Reply
|
Steve
|
9/25/2003 3:26:40 PM
|
|
While it was 25/9/03 11:17 am throughout the UK, TT (Tom Tempelaere)
sprinkled little black dots on a white screen, and they fell thus:
> Hi ,
>
> Is it possible to know what caused a focus lost event? A user that presses
> TAB (caused by keyboard) or a use clicks on another component with the mouse
> (caused by mouse). I need to distinguish between these two.
Why?
Stewart.
--
My e-mail is valid but not my primary mailbox. Please keep replies on
on the 'group where everyone may benefit.
|
|
0
|
|
|
|
Reply
|
Stewart
|
9/26/2003 2:35:13 PM
|
|
"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message
news:bl1ir1$gal$2@sun-cc204.lut.ac.uk...
> While it was 25/9/03 11:17 am throughout the UK, TT (Tom Tempelaere)
> sprinkled little black dots on a white screen, and they fell thus:
>
> > Hi ,
> >
> > Is it possible to know what caused a focus lost event? A user that
presses
> > TAB (caused by keyboard) or a use clicks on another component with the
mouse
> > (caused by mouse). I need to distinguish between these two.
>
> Why?
>
> Stewart.
Actually I'm constructing a validation scheme. For instance it could be
possible for a user to enter an invalid entry, but still be able to press a
button using mouse (usually the close button). However, the focus cannot
change using the keyboard (TAB) if the entry is invalid.
So I need information on what caused the focus change (mouse or keyboard) to
pass this information to the validation scheme.
Another question would be: how could I get this information in an
InputVerifier (InputVerifier.shouldYieldFocus/verify)? And how can I know
what is the component that is to receive the focus if you return true from
InputVerifier.shouldYieldFocus?
These are questions I cannot answer becos I'm a bit of a newbie in Java GUI
programming. We're converting an MFC project to Java, and this is definitely
HARD.
Thanks for any input.
PS: I dropped the idea of using focusLost handlers to do input validation,
because you can't show dialogs then. If you show a dialog in such a handler,
and you click on a different application, the program hangs.
Tom.
|
|
0
|
|
|
|
Reply
|
TiTi
|
9/26/2003 2:51:14 PM
|
|
"TT \(Tom Tempelaere\)" <_N_OSPAMtiti____@hotmail.comMAPSO_N_> wrote:
>Hi ,
>
>Is it possible to know what caused a focus lost event? A user that presses
>TAB (caused by keyboard) or a use clicks on another component with the mouse
>(caused by mouse). I need to distinguish between these two.
>
>Thanks,
I have not tried this in Java. However, it should be possible to set
and clear a "Mouse Down" flag in the MouseEvent which can be tested in
the FocusEvent.
|
|
0
|
|
|
|
Reply
|
David
|
9/26/2003 3:32:49 PM
|
|
"David Segall" <david@segall.net> wrote in message
news:snm8nvkas2ovg038fovgaju5q5qlbkthf5@4ax.com...
> "TT \(Tom Tempelaere\)" <_N_OSPAMtiti____@hotmail.comMAPSO_N_> wrote:
>
> >Hi ,
> >
> >Is it possible to know what caused a focus lost event? A user that
presses
> >TAB (caused by keyboard) or a use clicks on another component with the
mouse
> >(caused by mouse). I need to distinguish between these two.
> >
> >Thanks,
> I have not tried this in Java. However, it should be possible to set
> and clear a "Mouse Down" flag in the MouseEvent which can be tested in
> the FocusEvent.
Would the mouse event occur (be handled) before a lost focus event?
Would the mouse event occur (be handled) before any input validation using
InputVerifier?
Does anyone know of a good site that explains the flow of events, and when
they occur (in what order)?
Thanks,
Tom.
|
|
0
|
|
|
|
Reply
|
TT
|
9/26/2003 4:52:46 PM
|
|
While it was 26/9/03 3:51 pm throughout the UK, TiTi sprinkled little
black dots on a white screen, and they fell thus:
<snip>
> Actually I'm constructing a validation scheme. For instance it could
> be possible for a user to enter an invalid entry, but still be able
> to press a button using mouse (usually the close button). However,
> the focus cannot change using the keyboard (TAB) if the entry is
> invalid.
<snip>
I'm confused. Why should mouse users be able to fill in the form in
whatever order they wish, while people who for some reason cannot use a
mouse are forced to climb through your net?
Do you really need to validate each field as soon as the luser exits it?
Why not when pressing OK or something?
If you've a genuine reason for validating on exit from a control, and
keeping the luser stranded until he/she/it has provided acceptable
input, then certainly a much less arbitrary approach is to interrogate
where the focus went from the control. Use
FocusEvent.getOppositeComponent().
Stewart.
--
My e-mail is valid but not my primary mailbox. Please keep replies on
on the 'group where everyone may benefit.
|
|
0
|
|
|
|
Reply
|
Stewart
|
9/26/2003 5:47:34 PM
|
|
"TT \(Tom Tempelaere\)" <_N_OSPAMtiti____@hotmail.comMAPSO_N_> wrote:
>"David Segall" <david@segall.net> wrote in message
>news:snm8nvkas2ovg038fovgaju5q5qlbkthf5@4ax.com...
>> "TT \(Tom Tempelaere\)" <_N_OSPAMtiti____@hotmail.comMAPSO_N_> wrote:
>>
>> >Hi ,
>> >
>> >Is it possible to know what caused a focus lost event? A user that
>presses
>> >TAB (caused by keyboard) or a use clicks on another component with the
>mouse
>> >(caused by mouse). I need to distinguish between these two.
>> >
>> >Thanks,
>> I have not tried this in Java. However, it should be possible to set
>> and clear a "Mouse Down" flag in the MouseEvent which can be tested in
>> the FocusEvent.
>
>Would the mouse event occur (be handled) before a lost focus event?
>Would the mouse event occur (be handled) before any input validation using
>InputVerifier?
I am not confident about my answer but I believe that the events in
"this" component are handled before the mouse down event in the "next"
component. You would need to determine the state of the mouse in the
got focus event and apply it to the previous component.
>Does anyone know of a good site that explains the flow of events, and when
>they occur (in what order)?
>
>Thanks,
>Tom.
>
|
|
0
|
|
|
|
Reply
|
David
|
9/27/2003 2:48:30 PM
|
|
|
7 Replies
501 Views
(page loaded in 0.312 seconds)
|