Java Code Examples for sun.awt.SunToolkit#areExtraMouseButtonsEnabled()
The following examples show how to use
sun.awt.SunToolkit#areExtraMouseButtonsEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CPlatformResponder.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 2
Source File: CPlatformResponder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 3
Source File: CPlatformResponder.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 4
Source File: CPlatformResponder.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 5
Source File: CPlatformResponder.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 6
Source File: CPlatformResponder.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 7
Source File: CPlatformResponder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 8
Source File: CPlatformResponder.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absX, int absY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absX, absY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 9
Source File: CPlatformResponder.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 10
Source File: CPlatformResponder.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 11
Source File: CTrayIcon.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private void handleMouseEvent(NSEvent nsEvent) { int buttonNumber = nsEvent.getButtonNumber(); final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = nsEvent.getClickCount(); } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, nsEvent.getModifierFlags()); boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); int eventButtonMask = (jbuttonNumber > 0)? MouseEvent.getMaskForButton(jbuttonNumber) : 0; long when = System.currentTimeMillis(); if (jeventType == MouseEvent.MOUSE_PRESSED) { mouseClickButtons |= eventButtonMask; } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { mouseClickButtons = 0; } // The MouseEvent's coordinates are relative to screen int absX = nsEvent.getAbsX(); int absY = nsEvent.getAbsY(); MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); mouseEvent.setSource(target); postEvent(mouseEvent); // fire ACTION event if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { final String cmd = target.getActionCommand(); final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); postEvent(event); } // synthesize CLICKED event if (jeventType == MouseEvent.MOUSE_RELEASED) { if ((mouseClickButtons & eventButtonMask) != 0) { MouseEvent clickEvent = new MouseEvent(dummyFrame, MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); clickEvent.setSource(target); postEvent(clickEvent); } mouseClickButtons &= ~eventButtonMask; } }
Example 12
Source File: CTrayIcon.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private void handleMouseEvent(NSEvent nsEvent) { int buttonNumber = nsEvent.getButtonNumber(); final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = nsEvent.getClickCount(); } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, nsEvent.getModifierFlags()); boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); int eventButtonMask = (jbuttonNumber > 0)? MouseEvent.getMaskForButton(jbuttonNumber) : 0; long when = System.currentTimeMillis(); if (jeventType == MouseEvent.MOUSE_PRESSED) { mouseClickButtons |= eventButtonMask; } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { mouseClickButtons = 0; } // The MouseEvent's coordinates are relative to screen int absX = nsEvent.getAbsX(); int absY = nsEvent.getAbsY(); MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); mouseEvent.setSource(target); postEvent(mouseEvent); // fire ACTION event if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { final String cmd = target.getActionCommand(); final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); postEvent(event); } // synthesize CLICKED event if (jeventType == MouseEvent.MOUSE_RELEASED) { if ((mouseClickButtons & eventButtonMask) != 0) { MouseEvent clickEvent = new MouseEvent(dummyFrame, MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); clickEvent.setSource(target); postEvent(clickEvent); } mouseClickButtons &= ~eventButtonMask; } }
Example 13
Source File: CTrayIcon.java From hottub with GNU General Public License v2.0 | 4 votes |
private void handleMouseEvent(NSEvent nsEvent) { int buttonNumber = nsEvent.getButtonNumber(); final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = nsEvent.getClickCount(); } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, nsEvent.getModifierFlags()); boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); int eventButtonMask = (jbuttonNumber > 0)? MouseEvent.getMaskForButton(jbuttonNumber) : 0; long when = System.currentTimeMillis(); if (jeventType == MouseEvent.MOUSE_PRESSED) { mouseClickButtons |= eventButtonMask; } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { mouseClickButtons = 0; } // The MouseEvent's coordinates are relative to screen int absX = nsEvent.getAbsX(); int absY = nsEvent.getAbsY(); MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); mouseEvent.setSource(target); postEvent(mouseEvent); // fire ACTION event if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { final String cmd = target.getActionCommand(); final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); postEvent(event); } // synthesize CLICKED event if (jeventType == MouseEvent.MOUSE_RELEASED) { if ((mouseClickButtons & eventButtonMask) != 0) { MouseEvent clickEvent = new MouseEvent(dummyFrame, MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); clickEvent.setSource(target); postEvent(clickEvent); } mouseClickButtons &= ~eventButtonMask; } }
Example 14
Source File: CTrayIcon.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private void handleMouseEvent(NSEvent nsEvent) { int buttonNumber = nsEvent.getButtonNumber(); final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = nsEvent.getClickCount(); } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, nsEvent.getModifierFlags()); boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); int eventButtonMask = (jbuttonNumber > 0)? MouseEvent.getMaskForButton(jbuttonNumber) : 0; long when = System.currentTimeMillis(); if (jeventType == MouseEvent.MOUSE_PRESSED) { mouseClickButtons |= eventButtonMask; } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { mouseClickButtons = 0; } // The MouseEvent's coordinates are relative to screen int absX = nsEvent.getAbsX(); int absY = nsEvent.getAbsY(); MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); mouseEvent.setSource(target); postEvent(mouseEvent); // fire ACTION event if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { final String cmd = target.getActionCommand(); final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); postEvent(event); } // synthesize CLICKED event if (jeventType == MouseEvent.MOUSE_RELEASED) { if ((mouseClickButtons & eventButtonMask) != 0) { MouseEvent clickEvent = new MouseEvent(dummyFrame, MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); clickEvent.setSource(target); postEvent(clickEvent); } mouseClickButtons &= ~eventButtonMask; } }
Example 15
Source File: CTrayIcon.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void handleMouseEvent(NSEvent nsEvent) { int buttonNumber = nsEvent.getButtonNumber(); final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = nsEvent.getClickCount(); } int jmodifiers = NSEvent.nsToJavaModifiers( nsEvent.getModifierFlags()); boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); int eventButtonMask = (jbuttonNumber > 0)? MouseEvent.getMaskForButton(jbuttonNumber) : 0; long when = System.currentTimeMillis(); if (jeventType == MouseEvent.MOUSE_PRESSED) { mouseClickButtons |= eventButtonMask; } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { mouseClickButtons = 0; } // The MouseEvent's coordinates are relative to screen int absX = nsEvent.getAbsX(); int absY = nsEvent.getAbsY(); MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); mouseEvent.setSource(target); postEvent(mouseEvent); // fire ACTION event if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { final String cmd = target.getActionCommand(); final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); postEvent(event); } // synthesize CLICKED event if (jeventType == MouseEvent.MOUSE_RELEASED) { if ((mouseClickButtons & eventButtonMask) != 0) { MouseEvent clickEvent = new MouseEvent(dummyFrame, MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); clickEvent.setSource(target); postEvent(clickEvent); } mouseClickButtons &= ~eventButtonMask; } }
Example 16
Source File: CTrayIcon.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private void handleMouseEvent(NSEvent nsEvent) { int buttonNumber = nsEvent.getButtonNumber(); final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = nsEvent.getClickCount(); } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, nsEvent.getModifierFlags()); boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); int eventButtonMask = (jbuttonNumber > 0)? MouseEvent.getMaskForButton(jbuttonNumber) : 0; long when = System.currentTimeMillis(); if (jeventType == MouseEvent.MOUSE_PRESSED) { mouseClickButtons |= eventButtonMask; } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { mouseClickButtons = 0; } // The MouseEvent's coordinates are relative to screen int absX = nsEvent.getAbsX(); int absY = nsEvent.getAbsY(); MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); mouseEvent.setSource(target); postEvent(mouseEvent); // fire ACTION event if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { final String cmd = target.getActionCommand(); final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); postEvent(event); } // synthesize CLICKED event if (jeventType == MouseEvent.MOUSE_RELEASED) { if ((mouseClickButtons & eventButtonMask) != 0) { MouseEvent clickEvent = new MouseEvent(dummyFrame, MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); clickEvent.setSource(target); postEvent(clickEvent); } mouseClickButtons &= ~eventButtonMask; } }
Example 17
Source File: CTrayIcon.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private void handleMouseEvent(NSEvent nsEvent) { int buttonNumber = nsEvent.getButtonNumber(); final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = nsEvent.getClickCount(); } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, nsEvent.getModifierFlags()); boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); int eventButtonMask = (jbuttonNumber > 0)? MouseEvent.getMaskForButton(jbuttonNumber) : 0; long when = System.currentTimeMillis(); if (jeventType == MouseEvent.MOUSE_PRESSED) { mouseClickButtons |= eventButtonMask; } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { mouseClickButtons = 0; } // The MouseEvent's coordinates are relative to screen int absX = nsEvent.getAbsX(); int absY = nsEvent.getAbsY(); MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); mouseEvent.setSource(target); postEvent(mouseEvent); // fire ACTION event if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { final String cmd = target.getActionCommand(); final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); postEvent(event); } // synthesize CLICKED event if (jeventType == MouseEvent.MOUSE_RELEASED) { if ((mouseClickButtons & eventButtonMask) != 0) { MouseEvent clickEvent = new MouseEvent(dummyFrame, MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); clickEvent.setSource(target); postEvent(clickEvent); } mouseClickButtons &= ~eventButtonMask; } }
Example 18
Source File: CTrayIcon.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private void handleMouseEvent(NSEvent nsEvent) { int buttonNumber = nsEvent.getButtonNumber(); final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = nsEvent.getClickCount(); } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, nsEvent.getModifierFlags()); boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); int eventButtonMask = (jbuttonNumber > 0)? MouseEvent.getMaskForButton(jbuttonNumber) : 0; long when = System.currentTimeMillis(); if (jeventType == MouseEvent.MOUSE_PRESSED) { mouseClickButtons |= eventButtonMask; } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { mouseClickButtons = 0; } // The MouseEvent's coordinates are relative to screen int absX = nsEvent.getAbsX(); int absY = nsEvent.getAbsY(); MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); mouseEvent.setSource(target); postEvent(mouseEvent); // fire ACTION event if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { final String cmd = target.getActionCommand(); final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); postEvent(event); } // synthesize CLICKED event if (jeventType == MouseEvent.MOUSE_RELEASED) { if ((mouseClickButtons & eventButtonMask) != 0) { MouseEvent clickEvent = new MouseEvent(dummyFrame, MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); clickEvent.setSource(target); postEvent(clickEvent); } mouseClickButtons &= ~eventButtonMask; } }
Example 19
Source File: CTrayIcon.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private void handleMouseEvent(NSEvent nsEvent) { int buttonNumber = nsEvent.getButtonNumber(); final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = nsEvent.getClickCount(); } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, nsEvent.getModifierFlags()); boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); int eventButtonMask = (jbuttonNumber > 0)? MouseEvent.getMaskForButton(jbuttonNumber) : 0; long when = System.currentTimeMillis(); if (jeventType == MouseEvent.MOUSE_PRESSED) { mouseClickButtons |= eventButtonMask; } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { mouseClickButtons = 0; } // The MouseEvent's coordinates are relative to screen int absX = nsEvent.getAbsX(); int absY = nsEvent.getAbsY(); MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); mouseEvent.setSource(target); postEvent(mouseEvent); // fire ACTION event if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { final String cmd = target.getActionCommand(); final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); postEvent(event); } // synthesize CLICKED event if (jeventType == MouseEvent.MOUSE_RELEASED) { if ((mouseClickButtons & eventButtonMask) != 0) { MouseEvent clickEvent = new MouseEvent(dummyFrame, MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); clickEvent.setSource(target); postEvent(clickEvent); } mouseClickButtons &= ~eventButtonMask; } }
Example 20
Source File: CTrayIcon.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private void handleMouseEvent(NSEvent nsEvent) { int buttonNumber = nsEvent.getButtonNumber(); final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = nsEvent.getClickCount(); } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, nsEvent.getModifierFlags()); boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); int eventButtonMask = (jbuttonNumber > 0)? MouseEvent.getMaskForButton(jbuttonNumber) : 0; long when = System.currentTimeMillis(); if (jeventType == MouseEvent.MOUSE_PRESSED) { mouseClickButtons |= eventButtonMask; } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { mouseClickButtons = 0; } // The MouseEvent's coordinates are relative to screen int absX = nsEvent.getAbsX(); int absY = nsEvent.getAbsY(); MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); mouseEvent.setSource(target); postEvent(mouseEvent); // fire ACTION event if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { final String cmd = target.getActionCommand(); final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); postEvent(event); } // synthesize CLICKED event if (jeventType == MouseEvent.MOUSE_RELEASED) { if ((mouseClickButtons & eventButtonMask) != 0) { MouseEvent clickEvent = new MouseEvent(dummyFrame, MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); clickEvent.setSource(target); postEvent(clickEvent); } mouseClickButtons &= ~eventButtonMask; } }