Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Getting a reference to the OK button in Dialog
Getting a reference to the OK button in Dialog [message #464948] Thu, 01 December 2005 11:43 Go to next message
Matthew Campbell is currently offline Matthew Campbell
Messages: 2
Registered: July 2009
Junior Member
Hi All,

Eclipse 3.2M3
OS X 10.4.3

quick question regards OK button in a org.eclipse.jface.dialogs.Dialog.

I've extended the class to build my own dialog. I'd like to grab a
reference to the default OK button, however

getOKButton()

is depreciated and

etButton(IDialogConstants.OK_ID)

returns null. Is this correct behaviour? Am I doing something wrong?

Cheers

Matt
Re: Getting a reference to the OK button in Dialog [message #464950 is a reply to message #464948] Thu, 01 December 2005 11:50 Go to previous messageGo to next message
Gail Jakubowski is currently offline Gail Jakubowski
Messages: 36
Registered: July 2009
Member
You can override createButton and keep a reference to the okButton:

protected Button createButton(Composite parent, int id, String label,
boolean defaultButton) {
Button button = super.createButton(parent, id, label, defaultButton);
if (id == IDialogConstants.OK_ID) {
okButton = button;
}
return button;
}

"Matt Campbell" <matt@digitalbubblebath.com> wrote in message
news:918a3c692af4d89868ed0f68da4a7dd7$1@www.eclipse.org...
>
> Hi All,
>
> Eclipse 3.2M3
> OS X 10.4.3
>
> quick question regards OK button in a org.eclipse.jface.dialogs.Dialog.
>
> I've extended the class to build my own dialog. I'd like to grab a
> reference to the default OK button, however
> getOKButton()
> is depreciated and
> etButton(IDialogConstants.OK_ID)
>
> returns null. Is this correct behaviour? Am I doing something wrong?
>
> Cheers
>
> Matt
>
Re: Getting a reference to the OK button in Dialog [message #464953 is a reply to message #464950] Thu, 01 December 2005 12:36 Go to previous messageGo to next message
Matthew Campbell is currently offline Matthew Campbell
Messages: 2
Registered: July 2009
Junior Member
Thank you Gail, great suggestion, it worked a treat.

Matt
Re: Getting a reference to the OK button in Dialog [message #464963 is a reply to message #464948] Fri, 02 December 2005 03:53 Go to previous message
Yves Harms is currently offline Yves Harms
Messages: 80
Registered: July 2009
Member
If you just want to listen to SelectionEvents on the OK button, you can
simply overload Dialog.okPressed().

Yves

>
> Hi All,
>
> Eclipse 3.2M3
> OS X 10.4.3
>
> quick question regards OK button in a org.eclipse.jface.dialogs.Dialog.
>
> I've extended the class to build my own dialog. I'd like to grab a
> reference to the default OK button, however
> getOKButton()
> is depreciated and
> etButton(IDialogConstants.OK_ID)
>
> returns null. Is this correct behaviour? Am I doing something wrong?
>
> Cheers
>
> Matt
>
Previous Topic:TreeViewer only has small +/- buttons
Next Topic:How to make styledText "visible" in other files.
Goto Forum:
  


Current Time: Fri Aug 01 20:43:16 EDT 2014

Powered by FUDForum. Page generated in 0.02195 seconds