Example usage for javafx.scene.input MouseEvent isPopupTrigger

List of usage examples for javafx.scene.input MouseEvent isPopupTrigger

Introduction

In this page you can find the example usage for javafx.scene.input MouseEvent isPopupTrigger.

Prototype

public final boolean isPopupTrigger() 

Source Link

Document

Returns true if this mouse event is the popup menu trigger event for the platform.

Usage

From source file:Main.java

public static java.awt.event.MouseEvent toAwt(final MouseEvent event) {
    final EventType type = event.getEventType();
    if (null == type) {
        return null;
    }/* w ww. j  a va 2 s . c o  m*/

    final int id;
    if (MouseEvent.MOUSE_MOVED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_MOVED;
    } else if (MouseEvent.MOUSE_DRAGGED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_DRAGGED;
    } else if (MouseEvent.MOUSE_CLICKED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_CLICKED;
    } else if (MouseEvent.MOUSE_PRESSED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_PRESSED;
    } else if (MouseEvent.MOUSE_RELEASED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_RELEASED;
    } else if (MouseEvent.MOUSE_ENTERED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_ENTERED;
    } else if (MouseEvent.MOUSE_EXITED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_EXITED;
    } else {
        return null;
    }

    final int button;
    if (event.isPrimaryButtonDown()) {
        button = java.awt.event.MouseEvent.BUTTON1;
    } else if (event.isMiddleButtonDown()) {
        button = java.awt.event.MouseEvent.BUTTON2;
    } else if (event.isSecondaryButtonDown()) {
        button = java.awt.event.MouseEvent.BUTTON3;
    } else {
        button = java.awt.event.MouseEvent.NOBUTTON;
    }

    final long when = -1;
    final int modifiers = modifiers(event);
    final int x = (int) event.getX();
    final int y = (int) event.getY();
    final int xAbs = Integer.MAX_VALUE;
    final int yAbs = Integer.MAX_VALUE;
    final int count = event.getClickCount();
    boolean popup = event.isPopupTrigger();
    if (MouseEvent.MOUSE_CLICKED.equals(type) && event.isMetaDown()) {
        // mack books use meta flag for right-clicks
        popup = true;
    }
    return new java.awt.event.MouseEvent(empty, id, when, modifiers, x, y, xAbs, yAbs, count, popup, button);
}