changeset 4298:a24be2f5230e

RT-30703: Quick VK button pressings cause exception
author Elina Kleyman <elina.kleyman@oracle.com>
date Tue, 16 Jul 2013 13:49:30 +0300
parents 06979c6310cd
children e3c3c884cce1
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/FXVKSkin.java
diffstat 1 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/FXVKSkin.java	Tue Jul 16 11:03:29 2013 +0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/FXVKSkin.java	Tue Jul 16 13:49:30 2013 +0300
@@ -561,21 +561,20 @@
             if (fxvk != secondaryVK && secondaryPopup != null && secondaryPopup.isShowing()) {
                 return;
             }
-            Node target = fxvk.getAttachedNode();
-            if (target instanceof EventTarget) {
-                target.fireEvent(event(KeyEvent.KEY_PRESSED));
-                target.fireEvent(event(KeyEvent.KEY_TYPED));
-                target.fireEvent(event(KeyEvent.KEY_RELEASED));
-            }
+            sendKeyEvents();
             if (fxvk == secondaryVK) {
                 showSecondaryVK(null);
             }
-          
             super.release();
         }
 
-        protected KeyEvent event(EventType<KeyEvent> type) {
-            return new KeyEvent(type, chars, "", KeyCode.UNDEFINED, shiftDown, false, false, false); 
+        protected void sendKeyEvents() {
+            Node target = fxvk.getAttachedNode();
+            if (target instanceof EventTarget) {
+                if (chars != null) {
+                    target.fireEvent(new KeyEvent(KeyEvent.KEY_TYPED, chars, "", KeyCode.UNDEFINED, shiftDown, false, false, false));
+                }
+            }
         }
     }
 
@@ -660,11 +659,12 @@
             setId(letter);
         }
 
-        protected KeyEvent event(EventType<KeyEvent> type) {
-            if (type == KeyEvent.KEY_PRESSED || type == KeyEvent.KEY_RELEASED) {
-                return new KeyEvent(type, chars, chars, code, shiftDown, false, false, false);                                          
-            } else {
-                return super.event(type);
+        protected void sendKeyEvents() {
+            Node target = fxvk.getAttachedNode();
+            if (target instanceof EventTarget) {               
+                target.fireEvent(new KeyEvent(KeyEvent.KEY_PRESSED, KeyEvent.CHAR_UNDEFINED, chars, code, shiftDown, false, false, false));
+                target.fireEvent(new KeyEvent(KeyEvent.KEY_TYPED, chars, "", KeyCode.UNDEFINED, shiftDown, false, false, false));
+                target.fireEvent(new KeyEvent(KeyEvent.KEY_RELEASED, KeyEvent.CHAR_UNDEFINED, chars, code, shiftDown, false, false, false));
             }
         }
     }
@@ -908,7 +908,7 @@
                             } else if ("$tab".equals(chars)) {
                                 key = new KeyCodeKey("tab", "\t", KeyCode.TAB);
                             } else if ("$space".equals(chars)) {
-                                key = new CharKey(" ", null, null);
+                                key = new CharKey(" ", " ", null);
                             } else if ("$clear".equals(chars)) {
                                 key = new SuperKey("clear", "");
                             } else if ("$.org".equals(chars)) {