<Swing Dev> Mouse click cause MOUSE_EXITED and MOUSE_ENTERED event on macOS
Reto Merz
reto.merz at abacus.ch
Tue Apr 25 16:13:45 UTC 2017
Hello Dmitry,
Thank you for the info! Yes it seems that this was a duplicate of JDK-8050478,
I can confirm that the issue is fixed in JDK 8 u152 and JDK 9 b164.
Regards
Reto
Von: dmitry markov <dmitry.markov at oracle.com>
An: Reto Merz <reto.merz at abacus.ch>
Kopie: <swing-dev at openjdk.java.net>
Gesendet: 17.04.2017 21:22
Betreff: Re: <Swing Dev> Mouse click cause MOUSE_EXITED and MOUSE_ENTERED event on macOS
Hi Reto,
I guess, the problem you observed and JDK-8050478 may have the same root cause. The fix for JDK-8050478 was integrated into jdk9-b137 and jdk8u152 (not released yet). I recommend that you checked jdk9-b137 or higher to find out whether the issue is dupe of JDK-8050478 or not.
Regards,
Dmitry
On 12/04/2017 16:16, Reto Merz wrote:
Hi,
We have found out that a simple mouse click cause a MOUSE_EXITED and MOUSE_ENTERED on macOS in contrary to Windows.
This happen only when the click is performed on a dialog with a frame (owner) behind it.
It seems that the frame in the background cause the bug.
Steps to reproduce:
1. start reproducer (source below) -> a frame is opened with a button "Open dialog"
2. click on "Open dialog" -> a white dialog is opened, this dialog must overlay the frame
3. click in the white dialog -> see console output
Note that the reproducer logs mouse events to the console
(it might be useful to disable line wrapping in macOS terminal with "rput rmam").
On Windows the click cause this events (as expected):
java.awt.event.MouseEvent[MOUSE_PRESSED,(164,113),absolute(1942,763),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1]
java.awt.event.MouseEvent[MOUSE_RELEASED,(164,113),absolute(1942,763),button=1,modifiers=Button1,clickCount=1]
java.awt.event.MouseEvent[MOUSE_CLICKED,(164,113),absolute(1942,763),button=1,modifiers=Button1,clickCount=1]
On macOS (10.12.3) the click also cause MOUSE_EXITED and MOUSE_ENTERED:
java.awt.event.MouseEvent[MOUSE_PRESSED,(130,134),absolute(820,501),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1]
java.awt.event.MouseEvent[MOUSE_EXITED,(130,134),absolute(820,501),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0]
java.awt.event.MouseEvent[MOUSE_ENTERED,(130,134),absolute(820,501),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0]
java.awt.event.MouseEvent[MOUSE_RELEASED,(130,134),absolute(820,501),button=1,modifiers=Button1,clickCount=1]
java.awt.event.MouseEvent[MOUSE_CLICKED,(130,134),absolute(820,501),button=1,modifiers=Button1,clickCount=1]
Both tested with the latest public Java 8 release (from java.com):
java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
Why we get an additional MOUSE_EXITED and MOUSE_ENTERED on macOS?
It this a (known) bug or should we report this via bugreport.java.com?
Thanks
Reto
Reproducer:
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.WindowConstants;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.MouseEvent;
public class MouseExited {
public static void main(String[] args) throws Throwable {
EventQueue.invokeAndWait(() -> {
JFrame frame = new JFrame();
frame.setSize(500, 500);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JButton button = new JButton("Open dialog");
button.addActionListener(e -> {
JTable table = new JTable() {
@Override
protected void processMouseEvent(final MouseEvent e) {
System.out.println(e.toString());
}
};
JPanel dialogPane = new JPanel(new BorderLayout());
dialogPane.add(table);
JDialog dialog = new JDialog(frame);
dialog.setContentPane(dialogPane);
dialog.setModal(true);
dialog.setSize(300, 300);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
});
JPanel framePane = new JPanel(new BorderLayout());
framePane.add(button);
frame.setContentPane(framePane);
frame.setVisible(true);
});
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20170425/66b236f6/attachment.html>
More information about the swing-dev
mailing list