From 415f5c29ffae7cf5a26737da38e31cb84b652539 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Jun 2013 19:47:06 +0200 Subject: NEWT: Don't invoke external keyboardFocusHandler for auto-repeat keys (NewtCanvasAWT, ..) .. otherwise an auto repeated key would cause fast focus traversal, not intended. --- src/newt/classes/com/jogamp/newt/Window.java | 6 +++++- src/newt/classes/jogamp/newt/WindowImpl.java | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 0bebf330a..f63c03738 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -406,7 +406,11 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * Sets a {@link KeyListener} allowing focus traversal with a covered window toolkit like AWT. *

* The {@link KeyListener} methods are invoked prior to all other {@link KeyListener}'s - * allowing to suppress the {@link KeyEvent} via the {@link InputEvent#consumedTag}. + * allowing to suppress the {@link KeyEvent} via the {@link InputEvent#consumedTag} + * and to perform focus traversal with a 3rd party toolkit. + *

+ *

+ * The {@link KeyListener} methods are not invoked for {@link KeyEvent#isAutoRepeat() auto-repeat} events. *

* @param l */ diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 1ac97b07c..6787f0ab3 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2535,15 +2535,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected void consumeKeyEvent(KeyEvent e) { boolean consumedE = false; - if(null != keyboardFocusHandler) { + if( null != keyboardFocusHandler && !e.isAutoRepeat() ) { consumedE = propagateKeyEvent(e, keyboardFocusHandler); if(DEBUG_KEY_EVENT) { - System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumedE); + System.err.println("consumeKeyEvent(kfh): "+e+", keyboardFocusHandler consumed: "+consumedE); } } if(DEBUG_KEY_EVENT) { if( !consumedE ) { - System.err.println("consumeKeyEvent: "+e); + System.err.println("consumeKeyEvent(usr): "+e); } } for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) { -- cgit v1.2.3