Chris Bolton
Chris Bolton

Reputation: 2314

PropertyPage - Take control from Ok button

I am creating a Property Page. On the page, I have a Button named Add. I want the user to be able to hit enter and then the Add button is clicked and not the Ok button. Is this possible to do?

One option I have thought about is to add code in the performOk() method to check what needs to happen. But I don't like this approach unless it is the only way.

@Override
public boolean performOk(){
    //Do stuff
    //Ok hit. Should Add have been hit.
}

Upvotes: 0

Views: 48

Answers (1)

greg-449
greg-449

Reputation: 111142

The button used when Enter is pressed is the Shell 'default' button.

In a property page you could set it with:

getShell().setDefaultButton(buton);

You would have to make sure the default is reset whenever your property page becomes inactive.

I think changing the default away from the OK button might be very confusing.

Upvotes: 1

Related Questions