【发布时间】:2012-11-01 00:51:05
【问题描述】:
我正在开发一个 Eclipse RCP 应用程序。在扩展 MultiPageEditorPart 的类中,我试图将焦点设置到文本字段。但是 setFocus 方法总是返回 false。
我做错了什么?
MultiPageEditor 有各种页面,在这些页面中,有 Composite - 类。这些类包含文本字段。
这里是 sn-p:(errorPage 是一个 int,我的验证发现错误的页码)
if(!dataValid) {
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Fehler bei der Dateneingabe", stringBuilder.toString());
this.setActivePage(errorPage);
Composite errorComposite = (Composite) this.getControl(errorPage);
Control[] children = errorComposite.getChildren();
for (Control child : children) {
if(child instanceof Form) {
Form form = (Form) child;
Composite body = form.getBody();
Control[] formChildren = body.getChildren();
for (Control formChild : formChildren) {
if(formChild.equals(errorControl))
formChild.setFocus();
return dataValid;
}
}
}
}
【问题讨论】:
标签: java eclipse user-interface swt rcp