I have another question. I am using ModifyListener for a single text field to activate and deactivate the OK button in the swt dialog box. It works great.
Now I want to add a ModifyListener for another text field. I want the OK button to be activated only if there is one char in both min text fields.
This is the code for two fields:
descriptionText.addModifyListener(new ModifyListener(){
public void modifyText(ModifyEvent e) {
Text text = (Text) e.widget;
if (text.getText().length() == 0) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
if (text.getText().length() >= 1) {
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
}
});
}
second field:
ccidText.addModifyListener(new ModifyListener(){
public void modifyText(ModifyEvent e) {
Text text = (Text) e.widget;
if (text.getText().length() == 0) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
if (text.getText().length() >= 1){
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
}
});
}
I know that it does not work because there are no dependencies between the two buttons. How can i combine it?
I want to set ok-button false while both modifylistener detect char. If I delete all characters in one test field, the button should be deactivated again.
Thank.