432 scenePeer.menuEvent(e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), false);
433 }
434 }
435
436 /**
437 * Overrides the {@link java.awt.Component#processMouseEvent(MouseEvent)}
438 * method to dispatch the mouse event to the JavaFX scene attached to this
439 * {@code JFXPanel}.
440 *
441 * @param e the mouse event to dispatch to the JavaFX scene
442 */
443 @Override
444 protected void processMouseEvent(MouseEvent e) {
445 if ((e.getID() == MouseEvent.MOUSE_PRESSED) &&
446 (e.getButton() == MouseEvent.BUTTON1)) {
447 if (isFocusable() && !hasFocus()) {
448 requestFocus();
449 // The extra simulated mouse pressed event is removed by making the JavaFX scene focused.
450 // It is safe, because in JavaFX only the method "setFocused(true)" is called,
451 // which doesn't have any side-effects when called multiple times.
452 int focusCause = AbstractEvents.FOCUSEVENT_ACTIVATED;
453 stagePeer.setFocused(true, focusCause);
454 }
455 }
456
457 sendMouseEventToFX(e);
458 super.processMouseEvent(e);
459 }
460
461 /**
462 * Overrides the {@link java.awt.Component#processMouseMotionEvent(MouseEvent)}
463 * method to dispatch the mouse motion event to the JavaFX scene attached to
464 * this {@code JFXPanel}.
465 *
466 * @param e the mouse motion event to dispatch to the JavaFX scene
467 */
468 @Override
469 protected void processMouseMotionEvent(MouseEvent e) {
470 sendMouseEventToFX(e);
471 super.processMouseMotionEvent(e);
472 }
473
|
432 scenePeer.menuEvent(e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), false);
433 }
434 }
435
436 /**
437 * Overrides the {@link java.awt.Component#processMouseEvent(MouseEvent)}
438 * method to dispatch the mouse event to the JavaFX scene attached to this
439 * {@code JFXPanel}.
440 *
441 * @param e the mouse event to dispatch to the JavaFX scene
442 */
443 @Override
444 protected void processMouseEvent(MouseEvent e) {
445 if ((e.getID() == MouseEvent.MOUSE_PRESSED) &&
446 (e.getButton() == MouseEvent.BUTTON1)) {
447 if (isFocusable() && !hasFocus()) {
448 requestFocus();
449 // The extra simulated mouse pressed event is removed by making the JavaFX scene focused.
450 // It is safe, because in JavaFX only the method "setFocused(true)" is called,
451 // which doesn't have any side-effects when called multiple times.
452 if(stagePeer != null) {
453 int focusCause = AbstractEvents.FOCUSEVENT_ACTIVATED;
454 stagePeer.setFocused(true, focusCause);
455 }
456 }
457 }
458
459 sendMouseEventToFX(e);
460 super.processMouseEvent(e);
461 }
462
463 /**
464 * Overrides the {@link java.awt.Component#processMouseMotionEvent(MouseEvent)}
465 * method to dispatch the mouse motion event to the JavaFX scene attached to
466 * this {@code JFXPanel}.
467 *
468 * @param e the mouse motion event to dispatch to the JavaFX scene
469 */
470 @Override
471 protected void processMouseMotionEvent(MouseEvent e) {
472 sendMouseEventToFX(e);
473 super.processMouseMotionEvent(e);
474 }
475
|