Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Popup menu on Browser control doesn't disappear clicking outside menu
Popup menu on Browser control doesn't disappear clicking outside menu [message #1810538] Tue, 13 August 2019 09:53 Go to next message
Nicola  Zanaga is currently offline Nicola ZanagaFriend
Messages: 55
Registered: July 2009
Member
When creating a popup menu on a Browser control, menu behaves differently from other controls.

When a menu is opened for a control, clicking with left button outside the menu, but inside the control area, hides the menu.

This doesn't work on Browser control, the menu disappears only clicking to another control
In SWT this works correctly.

Below a code snippet:
Try to activate menu on Label and click on the Label: menu disappears
Try to activate menu on Browser and click on the Label: menu remains active

        Shell shell = new Shell(display);

        Label labelControl = new Label(shell, SWT.BORDER);
        labelControl.setBounds(0, 0, 200, 200);

        Browser browserControl = new Browser(shell, SWT.BORDER);
        browserControl.setBounds(200, 0, 200, 200);

        Button b1 = new Button(shell, SWT.BORDER);
        b1.setBounds(0, 200, 200, 50);
        b1.setText("popup menu on label");

        Button b2 = new Button(shell, SWT.BORDER);
        b2.setBounds(200, 200, 200, 50);
        b2.setText("popup menu on browser");

        b1.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                Menu m = new Menu(labelControl);
                MenuItem mi = new MenuItem(m, SWT.PUSH);
                mi.setText("menu linked to label");

                Point p = labelControl.toDisplay(0, 0);
                m.setLocation((int) (p.x + Math.random() * 200), (int) (p.y + Math.random() * 200));
                m.setVisible(true);
            }
        });
        b2.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                Menu m = new Menu(browserControl);
                MenuItem mi = new MenuItem(m, SWT.PUSH);
                mi.setText("menu linked to browser");

                Point p = browserControl.toDisplay(0, 0);
                m.setLocation((int) (p.x + Math.random() * 200), (int) (p.y + Math.random() * 200));
                m.setVisible(true);
            }
        });

        shell.open();



Re: Popup menu on Browser control doesn't disappear clicking outside menu [message #1810544 is a reply to message #1810538] Tue, 13 August 2019 10:22 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2327
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,

that's a known limitation. Browser control implementation is based on iframe. There is no connection between mouse events in the iframe and those in the main app HTML page. Menu will disappear only when the mouse event is triggered from the RAP main HTML document.

Best regards,
Ivan
Re: Popup menu on Browser control doesn't disappear clicking outside menu [message #1810603 is a reply to message #1810544] Wed, 14 August 2019 07:54 Go to previous message
Nicola  Zanaga is currently offline Nicola ZanagaFriend
Messages: 55
Registered: July 2009
Member
However, for my purpose, I solved adding this html part when loading html in Browser control:

<head>
<script>
    document.onmousedown=function() { if( event.button == 0 ) leftMouseDownCallback(); };
</script> 
</head>


In my control, I registered the browser function callback "leftMouseDownCallback" and close any previously opened menu
Previous Topic:Allineate RAP source with SWT [ GC.textExtent ]
Next Topic:Jface treeviewer refresh not working properly
Goto Forum:
  


Current Time: Mon Dec 09 10:42:24 GMT 2019

Powered by FUDForum. Page generated in 0.01562 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top