[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: JFace Dialog - change default focus
|
Joe Gagnon wrote:
I believe I was able to set up logic that allows this to work. If I
understand it right, the listener is basically mapping Return button
presses to Tab button presses. Is this correct?
The only problem with this is that when the focus finally reaches the
dialog OK button, pressing Return just moves focus on to the next item.
Is there a way to simply reset the "default" button (usually OK) of the
dialog to another button of our choosing? Keep in mind that the dialog
is just a container for a Composite that contains the button (or other
widget type) that we would like to set as the new default.
I tried looking at Shell.setDefaultButton(), but wasn't able to get it
to work.
Yes, shouldOverrideTraversal is your method, and its implementation
depends on what you want to do. My guess is that it should return false
whenever event.widget is a Button(SWT.PUSH) or the widget belongs to
another shell.
You can cause the filter to be removed as the dialog is closed by adding
a SWT.Dispose listener to the composite created in createDialogArea:
composite.addListener(SWT.Dispose, new Listener() {
public void handleEvent(Event e) {
display.removeListener(SWT.Traverse, overrideTraversalListener);
}
});
Just a thought, if your application creates all your form fields from
one factory object, it might be simpler to add a SWT.Traverse listener
to each form widget within that factory method rather than filtering all
events on the display.
Matthew