Try it with the latest source. On Dec 4, 2010, at 12:07 AM, ocean ocean wrote:
> Greg, > > This seems to work with TextInputs but not with TextAreas. When TextAreas > have focus it looks like they're consuming the ctrl+enter keypressed event. > Any other ideas? Is the only way to do, as Chris mentioned, somehow attaching > a listener to every component in the form? > > > On Sat, Nov 27, 2010 at 9:15 AM, Greg Brown <[email protected]> wrote: > I sent a reply to this last night but apparently it never came through. Try > listening for keyPressed() instead. That shouldn't be consumed by the text > inputs. Also, I'd suggest attaching the listener to the form instead of the > window if there is no reason not to. > > On Nov 26, 2010, at 8:19 PM, ocean ocean wrote: > > > I'm still having a lot of trouble implementing the default button > > functionality. Basically I'd like to have the user be able to type > > 'ctrl-enter' in various forms and have this automatically click on an 'OK' > > button that causes the form to be submitted. This seemed to have been > > working before but now it doesn't. I've tried adding a ComponentKeyListener > > to both a Dialog and a Window (obtained via Dialog.getWindow()), that > > reacts to ctrl-enter eg: > > > > dialog.getWindow().getComponentKeyListeners().add( > > new ComponentKeyListener.Adapter() { > > > > @Override > > public boolean keyTyped(Component component, char > > character) { > > if (character == Keyboard.KeyCode.ENTER && > > Keyboard.isPressed(Modifier.CTRL)) { > > System.out.println("*** ctrl-enter pressed"); > > return true; > > } else { > > return false; > > } > > } > > }); > > > > The problem seems to be that for forms that have TextInputs, this logic > > doesn't work when those TextInputs have focus. In this case the TextInputs > > consume the event. Is there a way to get my hands on the key typed before > > any controls in the window/dialog consume it? > >
