[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Problem with PRIMARY_MODAL dialog on OSX

We have a strange problem with PRIMARY_MODAL dialogs on OSX. Here are the steps to reproduce the problem:
- Open a primary modal dialog
- Switch to a different application
- Click on the titlebar of the original shell (not the dialog)
- Now, you can see that the yellow and the green lights on this parent shell are always on (before that they were grey unless you hovered above them)
- Close the dialog and note that the menu is not recovered. Usually the menu bar reappears as soon as the dialog is closed.


Here is a snippet that helps trying out this problem:

package org.eclipse.swt.snippets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;

public class SnippetModalDialogProblem {

    public static void main(String[] args) {
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setLayout(new GridLayout());
        Button b = new Button(shell, SWT.PUSH);
        b.setText("Open dialog");
        b.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                Shell dialog = new Shell(shell, SWT.PRIMARY_MODAL
                        | SWT.SHELL_TRIM);
                dialog.setSize(100, 50);
                dialog.open();
            }
        });
        Menu bar = new Menu(shell, SWT.BAR);
        shell.setMenuBar(bar);
        MenuItem item = new MenuItem(bar, SWT.CASCADE);
        item.setText("Menu");

        shell.pack();
        shell.open();

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