changeset 4667:4156455c1481

7125491: [macosx] Regression: A component can get unexpected keyTyped event. Reviewed-by: art, anthony
author ant
date Fri, 20 Jan 2012 14:41:38 +0300
parents 2a8bd80fe31d
children cade8d7be120
files src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Fri Jan 20 14:05:25 2012 +0300
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Fri Jan 20 14:41:38 2012 +0300
@@ -50,7 +50,8 @@
      * Handles mouse events.
      */
     public void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber,
-                                 int clickCount, int x, int y, int absoluteX, int absoluteY) {
+                                 int clickCount, int x, int y, int absoluteX, int absoluteY)
+    {
         int jeventType = isNpapiCallback ? NSEvent.npEventTypeToJavaEventType(eventType) :
                                            NSEvent.nsEventTypeToJavaEventType(eventType);
 
@@ -77,7 +78,8 @@
      * Handles scroll events.
      */
     public void handleScrollEvent(int x, int y, int modifierFlags,
-                                  double deltaX, double deltaY) {
+                                  double deltaX, double deltaY)
+    {
         int buttonNumber = CocoaConstants.kCGMouseButtonCenter;
         int jmodifiers = NSEvent.nsMouseModifiersToJavaMouseModifiers(buttonNumber, modifierFlags);
 
@@ -99,7 +101,8 @@
      * Handles key events.
      */
     public void handleKeyEvent(int eventType, int modifierFlags, String charsIgnoringMods,
-                               short keyCode) {
+                               short keyCode)
+    {
         boolean isFlagsChangedEvent =
             isNpapiCallback ? (eventType == CocoaConstants.NPCocoaEventFlagsChanged) :
                               (eventType == CocoaConstants.NSFlagsChanged);
@@ -138,8 +141,9 @@
         }
 
         int jmodifiers = NSEvent.nsKeyModifiersToJavaKeyModifiers(modifierFlags);
+        long when = System.currentTimeMillis();
 
-        peer.dispatchKeyEvent(jeventType, System.currentTimeMillis(), jmodifiers,
+        peer.dispatchKeyEvent(jeventType, when, jmodifiers,
                               jkeyCode, testChar, jkeyLocation);
 
         // That's the reaction on the PRESSED (not RELEASED) event as it comes to
@@ -154,7 +158,7 @@
 
             // emulating the codes from the ASCII table
             int shift = isCtrlDown ? isShiftDown ? 64 : 96 : 0;
-            peer.dispatchKeyEvent(KeyEvent.KEY_TYPED, System.currentTimeMillis(), jmodifiers,
+            peer.dispatchKeyEvent(KeyEvent.KEY_TYPED, when, jmodifiers,
                                   KeyEvent.VK_UNDEFINED, (char) (testChar - shift),
                                   KeyEvent.KEY_LOCATION_UNKNOWN);
         }