[ https://issues.apache.org/jira/browse/PIVOT-720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068312#comment-13068312 ]
Chris Bartlett edited comment on PIVOT-720 at 7/24/11 12:09 PM: ---------------------------------------------------------------- The thread in the description actually started out unrelated to this issue. The relevant part of the discussion starts here. http://apache-pivot-users.399431.n3.nabble.com/KeyListeners-on-ImageView-tp2600622p2622383.html Edited to reflect the discussion here http://apache-pivot-developers.417237.n3.nabble.com/jira-Created-PIVOT-720-Want-keystrokes-to-go-to-the-native-OS-window-that-has-focus-td2712839.html A quick (and hopefully accurate) summary of the current situation - Pivot currently tracks and exposes the focused org.apache.pivot.wtk.Component and active org.apache.pivot.wtk.Window via the following methods http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Component.html#getFocusedComponent() http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Window.html#getActiveWindow() - Pivot does not track or directly expose the state of any native OS windows that might house a org.apache.pivot.wtk.Display. - Pivot ensures that any Component returned by a call to getFocusedComponent() will reside in the active native OS window. When an OS window loses or gains focus, Pivot will set or clear its focused Component to ensure that the previous statement is true. A native OS window which loses focus will keep a reference any focused Pivot Component that it might contain before clearing the focused Pivot Component. If that Component non-null, it will be restored as the focused Component when the OS window regains focus. See http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/ApplicationContext.DisplayHost.html#processFocusEvent(java.awt.event.FocusEvent) org.apache.pivot.wtk.ApplicationContext.DisplayHost.processFocusEvent(FocusEvent) http://svn.apache.org/repos/asf/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java - There can either be 0 or 1 focused Pivot Components at any given moment. - Likewise there can either be 0 or 1 active Pivot Windows at any given moment. - These are independent of each other (i.e. The focused Component may not be part of the active Window) - If Pivot reports a focused Component, it will reside in the active native OS window. This is the basic flow of Pivot's current keystroke dispatching 1) If there *is* a focused Component, the keystroke will be directed to it. If this Component doesn't handle the keystroke, it will then directed to each of its ancestors until either the keystroke is handled or there are no more ancestors. (i.e. the org.apache.pivot.wtk.Display is the final Component to have its ComponentKeyListener called) 2) If there *isn't* a focused Component, the keystroke will be directed to application's Application.UnprocessedKeyHandler if it exists. was (Author: cbartlett): The thread in the description actually started out unrelated to this issue. The relevant part of the discussion starts here. http://apache-pivot-users.399431.n3.nabble.com/KeyListeners-on-ImageView-tp2600622p2622383.html A quick (and hopefully accurate) summary of the current situation Pivot currently tracks and exposes the focused org.apache.pivot.wtk.Component and active org.apache.pivot.wtk.Window via the following methods http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Component.html#getFocusedComponent() http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Window.html#getActiveWindow() Pivot does not track or directly expose the state of any native OS windows that might house a org.apache.pivot.wtk.Display. There can either be 0 or 1 focused Components at any given moment. Likewise there can either be 0 or 1 active Windows at any given moment. Both of these are independent of each other, and of which OS window might be 'active'. This is the basic flow of Pivot's current keystroke dispatching 1) If there *is* a focused Component, the keystroke will be directed to it. If this Component doesn't handle the keystroke, it will then directed to each of its ancestors until either the keystroke is handled or there are no more ancestors. (i.e. the org.apache.pivot.wtk.Display is the final Component to have its ComponentKeyListener called) 2) If there *isn't* a focused Component, the keystroke will be directed to application's Application.UnprocessedKeyHandler if it exists. > Want keystrokes to go to the native OS window that has focus > ------------------------------------------------------------ > > Key: PIVOT-720 > URL: https://issues.apache.org/jira/browse/PIVOT-720 > Project: Pivot > Issue Type: Improvement > Components: wtk > Affects Versions: 2.0 > Reporter: Bill van Melle > Fix For: 2.1 > > > If you use DesktopApplicationContext.createDisplay to create a new OS window, > and you want to handle keystrokes sent to that window, the only way your key > listener will get called is if there is a focused Pivot component in that > window. But not all interesting windows contain a focusable component, and > even when they do, there are often good reasons not to focus a particular > component by default. Meanwhile, if Pivot's notion of the currently focused > component is in a different OS window, keystrokes will go there, even though > it's not the window that appears to the user to have focus (as judged by the > native window system focus decoration), which is counterintuitive. > There is extensive discussion at > http://apache-pivot-users.399431.n3.nabble.com/KeyListeners-on-ImageView-td2600622.html -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira