[英]new SWT Shell without taking focus?
目前正在開發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();
對於諸如工具提示殼之類的東西,請使用:
new Shell(parent, SWT.ON_TOP | SWT.TOOL | SWT.NO_FOCUS);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.