Changing focus when the component is being activated. [message #875999] |
Wed, 23 May 2012 14:01  |
Eclipse User |
|
|
|
Hi,
I have a couple of input components on my SWT dialog. One of the input component is a Combo; but its choices depend on the "values" from the other input Text.
What I did is that I put a Listener on the "Activate" event for the combo box and at that time, try to capture the "values" from the other input Text components. If a component is "empty", I will popup a MessageBox and then I tried to switch focus to that "Text" component. But this switching doesn't seem to work since the focus is always back on the Combo. Does anyone have recommendations or maybe can point to what I do wrong here:
myCombo.addListener(SWT.Activate, new Listener() {
public void handleEvent(Event e) {
if (!errorEncounterd) {
setChoices(myCombo);
} else {
e.doit = false;
errorEncounterd = false;
}
}
});
private void setChoices(Combo myCombo) {
String input = myInputText.getText();
if (input.trim().length() == 0)
{
myInputText.setFocus();
}
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03964 seconds