On 5 March 2011 08:10, Bill van Melle <[email protected]> wrote:
> On Fri, Mar 4, 2011 at 12:47 AM, Chris Bartlett <[email protected]>wrote: >> >> Would the above approach meet your requirements? If not, please explain >> in more detail the structure of your GUI and the behaviour that you would >> like to see so that we can think about how to achieve it. >> > > I create additional top-level windows for things (usually dialogs of some > sort) that are larger than Sheets are appropriate for (and that's not very > large in an app where I let the user reshape the original window pretty much > arbitrarily). My immediate need for a key handler there is to allow Escape > to cancel the window. But I could imagine wanting other keyboard shortcuts, > such as something to navigate among tabs in a TabPane (an unsolved problem > you note). > > Could you clarify what you mean by 'top-level windows'? http://pivot.apache.org/tutorials/windows.html Are you referring to org.apache.pivot.wtk.Frame instances (or subclasses), or are you opening additional Displays via calls to DesktopApplicationContext.createDisplay(int, int, int, int, boolean, boolean, boolean, Window, DisplayListener) (example here http://svn.apache.org/repos/asf/pivot/trunk/tests/src/org/apache/pivot/tests/SheetTest.java ) Does the following this describe the essence of your scenario? An 'OS level' window containing one or more Pivot Frame instances? And you want the active Frame to receive key presses regardless of whether it contains a focused Component? If so, that certainly sounds reasonable to me. I'm not at a dev machine right now, but will check later to see how this plays out at present. I was initially hopeful when you mentioned that a Display can have a key > listener, since that's a sensible place to put top-level window key > listeners. There is a one-to-one mapping from Displays to OS-level windows, > right? Seems to me that the focused OS window should always be able to > detect keys, and if no child component has focus, it should still be > possible for the Display's key listener to run. Or am I misunderstanding > something? > > Yes, I think there is a 1:1 relationship between an OS WIndow and a Display. If the OS window has focus, but no Pivot Component inside of it has focus, the Application.UnprocessedKeyHandler will get the key presses. The Display's ComponentKeyListeners would only come into effect if there was a focused Component and the keyboard event was not consumed before it reached the Display. Chris
