Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge browser fires additional events, e.g. when opened via double click #1375

Open
dirkfauth opened this issue Jul 30, 2024 · 0 comments
Open
Labels
edge Edge Browser Windows Happens on Windows OS

Comments

@dirkfauth
Copy link

dirkfauth commented Jul 30, 2024

Describe the bug
We got a Bug report in NatTable that when opening an editor on double click, where the editor opens a Browser of type SWT.EDGE, the editor gets opened again after the first one is closed.

The reason is that the second click on double click seems not to be cleared from the "deferredEvents". Edge.callAndWait() calls Display.readAndDispatch() which in turn calls Display.runDeferredEvents(). This actually means we get an additional mouseUp event after handling the mouseDoubleClick event.

To Reproduce

  • Start the following snippet
  • Double click on the first button, which opens a Browser in a dialog. In the console you see that you get a mouseUp event and a mouseDoubleClick event
  • Double click on the second button "Open Edge Browser in Dialog". In the console you now see that after the mouseDoubleClick event, there is an additional mouseUp event.
public class SnippetEdgeEventIssue {
    public static void main(String[] args) {
        Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setText("Snippet Edge Event Issue");
        shell.setLayout(new RowLayout());

        Button browserButton = new Button(shell, SWT.PUSH);
        browserButton.setText("Open Browser in Dialog");
        browserButton.addMouseListener(new MouseListener() {

            @Override
            public void mouseUp(MouseEvent e) {
                System.out.println("mouse up");
            }

            @Override
            public void mouseDown(MouseEvent e) {
            }

            @Override
            public void mouseDoubleClick(MouseEvent e) {
                System.out.println("mouse double click");

                Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
                dialog.setLayout(new FillLayout());

                try {
                    Browser browser = new Browser(dialog, SWT.NONE);
                } catch (SWTError err) {
                    System.out.println("Could not instantiate Browser: " + err.getMessage());
                    display.dispose();
                    return;
                }

                dialog.open();
            }
        });

        Button browserEdgeButton = new Button(shell, SWT.PUSH);
        browserEdgeButton.setText("Open Edge Browser in Dialog");
        browserEdgeButton.addMouseListener(new MouseListener() {

            @Override
            public void mouseUp(MouseEvent e) {
                System.out.println("mouse up");
            }

            @Override
            public void mouseDown(MouseEvent e) {
            }

            @Override
            public void mouseDoubleClick(MouseEvent e) {
                System.out.println("mouse double click");

                Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
                dialog.setLayout(new FillLayout());

                try {
                    Browser browser = new Browser(dialog, SWT.EDGE);
                } catch (SWTError err) {
                    System.out.println("Could not instantiate Browser: " + err.getMessage());
                    display.dispose();
                    return;
                }

                dialog.open();
            }
        });

        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
}

Expected behavior
There should be only a mouseUp event followed by a mouseDoubleClick event. The additional mouseUp event should not be fired.

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)

Windows 11

  1. JRE/JDK version

Java 11

Version since
Eclipse or SWT version since when the behavior is seen: 4.24, haven't tested older versions. But it is reported for the current Eclipse version 2024-06.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
edge Edge Browser Windows Happens on Windows OS
Projects
None yet
Development

No branches or pull requests

2 participants