Reputation: 4647
I am using a swt table and have implemented an selectionListener
:
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
//...
}
});
I click on the first item and the listener works!
Now, after pressing a button, I want to select the next item in the table automaticaly. I have tried:
table.setFocus();
table.select(table.getSelectionIndex() + 1);
and
table.setFocus();
table.setSelection(table.getSelectionIndex() + 1);
The selection changes (blue color), but the selectionListener does not react?!
Maybe you can help me with this issue.
Thank you for your help!
Kind regards
Upvotes: 0
Views: 46
Reputation: 36884
That's by design (cf. this).
What you can do is the following:
table.setSelection(1);
table.notifyListeners(SWT.Selection, new Event());
Or even this:
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
methodCallHere();
}
});
and then
table.setSelection(1);
methodCallHere();
Upvotes: 2