[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: JFace Dialog - change default focus

Eric Rizzo wrote:

Joe Gagnon wrote:
We have a situation in our project where we display a dialog (using a JFace Dialog) and we want to change the default focus from the OK/Cancel buttons to a button (or other widget type) on the "body" of the dialog.

If you look at the code in Dialog.createButtonsForButtonBar() you'll see that the OK button is created there (via another method, createButton()) and specifed as the default (last argument to createButton()).
You can override createButtonsForButtonBar() to create the OK button NOT as the default and then set the default button to be whatever you want.
For setting your own default button, take a look into the Dialog.createButton() method, where you'll see that the setting of default button is done on the Shell.

Hope this helps,
	Eric

Yes, that does the trick. I was able to also to set a button in the Composite that sits in the dialog as the default button and it appears to work.