Popup menu on Browser control doesn't disappear clicking outside menu [message #1810538] |
Tue, 13 August 2019 09:53  |
Nicola Zanaga Messages: 56 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();
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03420 seconds