new SWT Shell 没有关注?
new SWT Shell without taking focus?
目前正在开发一个 Eclipse 插件,我想制作一个 Shell 在 created/shown 时不获取焦点的东西。
我试过使用 SWT.NO_FOCUS 但无济于事。
如何创建一个 Shell 而不会将注意力从另一个 app/window 上移开?
对于工具提示之类的东西 shell 使用:
new Shell(parent, SWT.ON_TOP | SWT.TOOL | SWT.NO_FOCUS);
下面的代码将打开一个新的 Shell
而不会将焦点从父对象上移开:
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Whosebug");
shell.setLayout(new GridLayout());
Button button = new Button(shell, SWT.PUSH);
button.setText("Open new Shell");
button.addListener(SWT.Selection, (event) -> {
Shell child = new Shell(shell);
child.setText("Child");
child.setVisible(true);
child.setSize(300,200);
});
shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
目前正在开发一个 Eclipse 插件,我想制作一个 Shell 在 created/shown 时不获取焦点的东西。
我试过使用 SWT.NO_FOCUS 但无济于事。
如何创建一个 Shell 而不会将注意力从另一个 app/window 上移开?
对于工具提示之类的东西 shell 使用:
new Shell(parent, SWT.ON_TOP | SWT.TOOL | SWT.NO_FOCUS);
下面的代码将打开一个新的 Shell
而不会将焦点从父对象上移开:
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Whosebug");
shell.setLayout(new GridLayout());
Button button = new Button(shell, SWT.PUSH);
button.setText("Open new Shell");
button.addListener(SWT.Selection, (event) -> {
Shell child = new Shell(shell);
child.setText("Child");
child.setVisible(true);
child.setSize(300,200);
});
shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();