[英]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.