Community
Participate
Working Groups
When getWorkbenchWindow().run(false, false, IRunnableWithProgress) is called, all of the workbench shells are temporarily disabled. Disabling the shells causes a FocusLost event to occur, which affects the behavior of the application. public class Bug68003 { static final int INITIAL = 0; static final int DRAGGING = 1; static final int ABORTED = 2; private static int state = INITIAL; public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(); shell.setLayout(new GridLayout()); final Canvas canvas = new Canvas(shell, SWT.BORDER); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); //Make the canvas focusable canvas.addKeyListener(new KeyAdapter(){}); final Label status = new Label(shell, SWT.BORDER); status.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); canvas.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { state = DRAGGING; status.setText("drag in progress"); shell.setEnabled(false); shell.setEnabled(true); } public void mouseUp(MouseEvent e) { if (state == DRAGGING) { status.setText("drag completed"); } state = INITIAL; } }); canvas.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { if (state == DRAGGING) { state = ABORTED; status.setText("Drag Aborted due to FocusLost"); } } }); shell.setSize(400,300); shell.open(); while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep(); } } Have not tested on other platforms. Any guesses as to whether this occurs across all platforms?
Yes. This was fixed for 3.0. Prior to that, under some circumstances and on some platforms, when you disabled a shell, focus was not reassigned. It was possible to type and have keys go to a child widget in a disabled shell. This has been fixed. Part of the fix means that focus out events happen because focus is reassigned.
What did you mean by focus is reassigned? to what? Reassigned to NULL?
Yes. Focus is reassigned to the desktop on Windows and elsewhere on the other platforms.