popup menu disappear with background thread [message #1727717] |
Fri, 25 March 2016 12:43  |
Eclipse User |
|
|
|
If you apply a menu to a control, the popup menu disappear if there is any background thread that executes some UI action.
If the background thread doesn't do any action, the menu stays correctly open.
I'm using RAP rap-3.0.2-SR2-20160201-1220
Below the snippet:
final Display display = new Display();
Shell shell = new Shell(display);
final Label t = new Label(shell, SWT.BORDER);
t.setBounds(0, 0, 200, 400);
t.addMenuDetectListener(new MenuDetectListener() {
@Override
public void menuDetected(MenuDetectEvent e) {
Menu m = new Menu(t);
MenuItem mi = new MenuItem(m, SWT.PUSH);
mi.setText("test");
m.setLocation(e.x, e.y);
m.setVisible(true);
while( !display.isDisposed() && !m.isDisposed() && m.getVisible() ) {
if( !display.readAndDispatch() )
display.sleep();
}
m.dispose();
}
});
ServerPushSession serverPushSession = new ServerPushSession();
serverPushSession.start();
Thread th = new Thread() {
int k = 0;
@Override
public void run() {
for( ;; ) {
try {
Thread.sleep(500);
} catch( InterruptedException e ) {
}
display.asyncExec(new Runnable() {
@Override
public void run() {
t.setText(String.valueOf(k++));
}
});
}
};
};
th.setDaemon(true);
th.start();
shell.open();
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() ) display.sleep();
}
display.dispose();
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.47470 seconds