< prev index next >

src/java.desktop/share/classes/java/awt/event/MouseEvent.java

Print this page

        

@@ -31,10 +31,12 @@
 import java.awt.Toolkit;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.awt.IllegalComponentStateException;
 import java.awt.MouseInfo;
+
+import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
 
 /**
  * An event which indicates that a mouse action occurred in a component.
  * A mouse action is considered to occur in a particular component if and only

@@ -330,10 +332,15 @@
      * @see #getClickCount()
      */
     int clickCount;
 
     /**
+     * Indicates whether the event is a result of a touch event.
+     */
+    private boolean causedByTouchEvent;
+
+    /**
      * Indicates which, if any, of the mouse buttons has changed state.
      *
      * The valid values are ranged from 0 to the value returned by the
      * {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()} method.
      * This range already includes constants {@code NOBUTTON}, {@code BUTTON1},

@@ -397,10 +404,21 @@
         } else {
             //It's expected that some toolkits (Headless,
             //whatever besides SunToolkit) could also operate.
             cachedNumberOfButtons = 3;
         }
+        AWTAccessor.setMouseEventAccessor(
+            new AWTAccessor.MouseEventAccessor() {
+                public boolean isCausedByTouchEvent(MouseEvent ev) {
+                    return ev.causedByTouchEvent;
+                }
+
+                public void setCausedByTouchEvent(MouseEvent ev,
+                    boolean causedByTouchEvent) {
+                    ev.causedByTouchEvent = causedByTouchEvent;
+                }
+            });
     }
 
     /**
      * Initialize JNI field and method IDs for fields that may be
      *  accessed from C.
< prev index next >