焦点停留在 shell 上,不再按 tab 键遍历
the focus sticks on the shell and it Traverses by tab key no more
我用 SWT 做了一个简单的 shell 内容两个按钮。
编译下面的代码后,当我在 shell 上按 Tab 键几次时,焦点从按钮一移动到按钮二,然后在 shell (平面)上移动;尽管按了tab键,焦点仍然在那里,不再遍历。
而 shell 的样式是 NO_FOCUS.
有人可以告诉我这个问题应该如何解决吗?
我正在使用:Windows 10 64 位,Java 8 64 位,swt v4.7.3,Eclipse neon(java SEE 开发人员),
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainWindows {
MainWindows() {
Display display = new Display();
Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.CENTER | SWT.NO_FOCUS | SWT.TOP);
shell.setText("test win");
shell.setLayout(new RowLayout());
shell.setSize(500, 500);
Button b1 = new Button(shell, SWT.PUSH);
Button b2 = new Button(shell, SWT.PUSH);
b1.setBounds(100, 100, 50, 50);
b2.setBounds(200, 200, 50, 50);
b1.setText("b1");
b2.setText("b2");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
static void main(String[] args) {
MainWindows mainWindows = new MainWindows();
}
}
我注意到,出现此问题是因为样式 SWT.CENTER 被错误地用作 Shell 构造函数的参数。
Style CENTER 对于小部件使用的对齐中心行为是常量:Button Label TableColumn
和 FormLayout
中的 FormAttachment
参考:Class SWT
我用 SWT 做了一个简单的 shell 内容两个按钮。
编译下面的代码后,当我在 shell 上按 Tab 键几次时,焦点从按钮一移动到按钮二,然后在 shell (平面)上移动;尽管按了tab键,焦点仍然在那里,不再遍历。
而 shell 的样式是 NO_FOCUS.
有人可以告诉我这个问题应该如何解决吗?
我正在使用:Windows 10 64 位,Java 8 64 位,swt v4.7.3,Eclipse neon(java SEE 开发人员),
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainWindows {
MainWindows() {
Display display = new Display();
Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.CENTER | SWT.NO_FOCUS | SWT.TOP);
shell.setText("test win");
shell.setLayout(new RowLayout());
shell.setSize(500, 500);
Button b1 = new Button(shell, SWT.PUSH);
Button b2 = new Button(shell, SWT.PUSH);
b1.setBounds(100, 100, 50, 50);
b2.setBounds(200, 200, 50, 50);
b1.setText("b1");
b2.setText("b2");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
static void main(String[] args) {
MainWindows mainWindows = new MainWindows();
}
}
我注意到,出现此问题是因为样式 SWT.CENTER 被错误地用作 Shell 构造函数的参数。
Style CENTER 对于小部件使用的对齐中心行为是常量:Button Label TableColumn
和 FormLayout
中的 FormAttachment
参考:Class SWT