私のアプリケーションには、いくつかの設定ページがあります。それらのいくつかでは、ユーザーはいくつかの項目を編集する必要があります。ユーザーがEnterkey-KEY を使用すると、OK ボタンにフォーカスがあるため、設定ダイアログ全体が閉じます。
では、どうすればこの動作を無効にできますか?
ページ上の任意の項目にフォーカスを設定できますが、押すEnterとダイアログが強制的に閉じられます。
デフォルトの Dialog を拡張し、次のメソッドをオーバーライドします。
@Override
protected void createButtonsForButtonBar(Composite parent) {
// Its the same as super.createButtonsForButtonBar(), but makes no default buttons by sending false.
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}