这是我的对话框类:InputDialog,它是用另一个视图中的按钮打开的。此对话框包含单个文本输入。
public class InputDialog extends Dialog{
public InputDialog(Shell parentShell) {
super(parentShell);
// TODO Auto-generated constructor stub
}
@Override
protected Control createDialogArea(Composite parent) {
parent.setLayout(new GridLayout(1, false));
Text txtName = new Text(parent, SWT.NONE);
return super.createDialogArea(parent);
}
@Override
protected void okPressed() {
// TODO Auto-generated method stub
super.okPressed();
}
}
这就是我打开对话框的方式:
buttAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
// TODO Auto-generated method stub
InputDialog dialog = new InputDialog(new Shell());
dialog.open();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
});
如何处理/读取对话框中返回或提交的值?