user2711115
user2711115

Reputation: 457

SWT Help button in TrayDialog

I have a class that extends TrayDialog and that has a help button. I have set the folowing:

setDialogHelpAvailable(true);
setHelpAvailable(true);

And I can't find how I'm supposed to implement the Help button in the lower left corner. I've tried

@Override
protected void buttonPressed(int buttonId) {
    super.buttonPressed(buttonId);
    if(buttonId == IDialogConstants.HELP_ID) {
        System.out.println("Help requested");
    }
}

But it doesn't work. I've seen Can't put content behind SWT Wizard Help Button but I have no performHelp() method because I'm not in a wizard.

What am I missing here? thanks

Upvotes: 1

Views: 1436

Answers (2)

YourReflection
YourReflection

Reputation: 395

I had the same problem and solved it by just adding a HelpListener to one of my controls:

Composite area.addHelpListener(new HelpListener() { 

    @Override public void helpRequested(HelpEvent e) { 
        System.out.println("This is the help info"); 
    }
});

and adding the following to my Constructor:

setDialogHelpAvailable(true);

Upvotes: 1

greg-449
greg-449

Reputation: 111217

When the help button is pressed TrayDialog looks for a control with a SWT.Help listener. It starts at the currently focused control and moves up through the control's parents until it finds a control with the listener (or runs out of controls).

You can set up a help listener that is connected to a 'help context' in the Eclipse help system using

PlatformUI.getWorkbench().getHelpSystem().setHelp(control, "context-id");

or you can write your own help listener.

Upvotes: 1

Related Questions