[英]How to set focus on an SWT TableItem
我有一个添加按钮,它将行添加到 SWT 表中,我实现了 TableEditor 来编辑行。
Button button = new Button(composite, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem item = new TableItem(table, SWT.NONE);
}
});
这是一段用于创建表的代码
table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
table.setBounds(0, 0, 240, 160);
toolkit.adapt(table);
toolkit.paintBordersFor(table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
当用户点击添加按钮时,将创建一行以允许用户进行编辑。 但是从用户的角度来看,创建或不创建行是不可见的,直到并且除非他选择该行并且启用了编辑器。
那么您能否建议如何将焦点设置在新添加的 TableItem 上?
参见 Table.setSelection() 和 Table.showItem() API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.