【发布时间】:2016-02-23 15:05:25
【问题描述】:
目前正在开发一个 Eclipse 插件,我想制作一个在创建/显示时不关注焦点的 Shell。
我尝试使用 SWT.NO_FOCUS 但无济于事。
如何在不将焦点从您所在的另一个应用程序/窗口上移开的情况下创建 Shell?
【问题讨论】:
目前正在开发一个 Eclipse 插件,我想制作一个在创建/显示时不关注焦点的 Shell。
我尝试使用 SWT.NO_FOCUS 但无济于事。
如何在不将焦点从您所在的另一个应用程序/窗口上移开的情况下创建 Shell?
【问题讨论】:
下面的代码将打开一个新的Shell,而不会将焦点从父级移开:
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("StackOverflow");
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();
【讨论】:
open(),因为那是你通常做的事情。
对于类似工具提示外壳使用:
new Shell(parent, SWT.ON_TOP | SWT.TOOL | SWT.NO_FOCUS);
【讨论】: