>> Can you clarify the 'no component currently has the focus' part?  Are
>> you saying this would only occur if there is no Pivot Component in the
>> entire app?
Doh!  Killer typo there.
That was supposed to say '...if there is no *focused* Pivot Component...'
I don't foresee too many arguments regarding which Component to
dispatch keyboard events to when the Pivot app has no Components!

On 21 July 2011 07:12, Greg Brown <gk_br...@verizon.net> wrote:
> No - I'm talking about the case when Component#getFocusedComponent() returns 
> null (for example, when an application starts up but fails to request initial 
> focus to some component). If any component has the focus, the key event will 
> bubble up to the display, so this workaround wouldn't be necessary.


>From my earlier email ...
> I thought the crucial part of this was to dispatch the event to the
> Display hosted in the OS window considered 'active', even if there is
> a focused Pivot Component in another Display.

I have seen occasions where one OS window (MS Windows XP 64) would be
highlighted/active/focused, but there was a focused Pivot Component in
a different Display.  This occurred often enough when investigating
during the original thread, as well as yesterday, that I thought it
was the intended behaviour.
(i.e. There is a focused TextInput in OS window 'A', click on the
chrome of OS window 'B' to activate it, but the TextInput remains
focused because focus was not explicitly cleared or set to another
Component.  Key strokes would be sent to the TextInput in window 'A'
because it is the focused Component)

Digging a little deeper suggests that
org.apache.pivot.wtk.ApplicationContext.DisplayHost.processFocusEvent(FocusEvent)
is designed to ensure that this scenario will not arise by clearing
and setting the focused Pivot Component on
java.awt.event.FocusEvent.FOCUS_LOST and
java.awt.event.FocusEvent.FOCUS_GAINED

And of course, now I that I want to investigate it further I haven't
yet been able to reliably replicate the situation. Perhaps it only
arises when running in Eclipse's debug mode, or through some
combination of java.awt.event.WindowEvents?
(WINDOW_ACTIVATED/WINDOW_DEACTIVATED perhaps)
http://download.oracle.com/javase/6/docs/api/java/awt/event/WindowEvent.html

Given the existing mechanism to ensure that the focused Pivot
Component will always be in the active OS window, forwarding the key
stroke to the Display would suffice for this ticket.

Any problems with focused Component remaining in a non active OS
window would a separate issue.

Reply via email to