我创建了具有复选框和两个单选按钮的复合控件。这类似于使用复选框控制单选按钮,即只有在选中复选框后才会启用单选按钮
我想在页面出现时将焦点设置在复选框上(使用 CTRl+TAB 进行复合遍历),它在未启用任何单选按钮的情况下工作正常。
如果选择了任何单选按钮,则焦点将转到该单选按钮而不是复选框。这是 Windows 默认行为,焦点应该在选定的单选按钮上吗?我怎样才能让焦点始终放在复选框上?我尝试在复选框上使用 setFocus,但这没有帮助。
所有这三个按钮都在一个组中。
这是示例代码
Composite composite = this;
GridData LData = new GridData();
LData.horizontalSpan = 1;
LData.horizontalAlignment = GridData.FILL;
LData.grabExcessHorizontalSpace = true;
LData.verticalAlignment = GridData.FILL;
LData.grabExcessVerticalSpace = true;
composite.setLayoutData(LData);
composite.setLayout(new GridLayout(1, false));
Label infoLabel = new Label(composite, SWT.NONE);
infoLabel.setText("Test");
rGroup = new Group(composite, SWT.NONE);
GridData rGroupLData = new GridData();
rGroupLData.grabExcessHorizontalSpace = true;
rGroupLData.horizontalAlignment = GridData.FILL;
rGroup.setLayoutData(rGroupLData);
GridLayout rGroupLayout = new GridLayout(5, false);
rGroup.setLayout(rGroupLayout);
checkBox1 = new Button(rGroup, SWT.CHECK);
checkBox1.setText("CheckBox");
GridData rcheckBox1LData = new GridData();
rcheckBox1LData.horizontalSpan = 5;
rcheckBox1LData.verticalAlignment = GridData.CENTER;
rcheckBox1LData.grabExcessHorizontalSpace = true;
rcheckBox1LData.horizontalAlignment = GridData.FILL;
checkBox1.setLayoutData(rcheckBox1LData);
GridData r1LData = new GridData();
r1LData.horizontalAlignment = GridData.CENTER;
r1LData.grabExcessHorizontalSpace = true;
r1LData.verticalAlignment = GridData.CENTER;
r1Numeric = new Button(rGroup, SWT.RADIO);
r1Numeric.setText("Radio1");
r1Numeric.setSelection(true);
r1Numeric.setLayoutData(r1LData);
r1Numeric.setEnabled(false);
GridData selR1LData = new GridData();
selR1LData.horizontalAlignment = GridData.CENTER;
selR1LData.grabExcessHorizontalSpace = true;
selR1LData.verticalAlignment = GridData.CENTER;
selR1Value = new Button(rGroup, SWT.NONE);
selR1Value
.setText("Select R1");
selR1Value.setLayoutData(selR1LData);
selR1Value.setEnabled(false);
GridData r2LData = new GridData();
r2LData.horizontalAlignment = GridData.CENTER;
r2LData.grabExcessHorizontalSpace = true;
r2LData.verticalAlignment = GridData.CENTER;
r2Numeric = new Button(rGroup, SWT.RADIO);
r2Numeric.setText("Radio2");
r2Numeric.setLayoutData(r2LData);
r2Numeric.setSelection(false);
r2Numeric.setEnabled(false);
GridData selR2LData = new GridData();
selR2LData.horizontalAlignment = GridData.CENTER;
selR2LData.grabExcessHorizontalSpace = true;
selR2LData.verticalAlignment = GridData.CENTER;
selR2Value = new Button(rGroup, SWT.NONE);
selR2Value
.setText("Select R2");
selR2Value.setLayoutData(selR2LData);
selR2Value.setEnabled(false);