429 popupTrigger);
430 }
431 if (e.isPopupTrigger()) {
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 // this focus request event goes to eventqueue and will be
450 // asynchronously handled so MOUSE_PRESSED event will not be
451 // honoured by FX immediately due to lack of focus in fx
452 // component. Fire the same MOUSE_PRESSED event after
453 // requestFocus() so that 2nd mouse press will be honoured
454 // since now fx have focus
455 jfxPanelIOP.postEvent(this, e);
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
|
429 popupTrigger);
430 }
431 if (e.isPopupTrigger()) {
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 // This fixes JDK-8087914 without causing JDK-8200224
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
|