leonbloy
leonbloy

Reputation: 75926

How to permanently disable the tray in SWT TrayDialog?

When F1 is pressed the default behaviour of a TrayDialog is to open the help tray (if not already opened), by calling openTray(). I don't want that behaviour (but I do want to use a ElementTreeSelectionDialog, which extends TrayDialog), and I don't know how to disable that.

I tried to add my own listener event filter for SWT.KeyDown and setting event.type = SWT.NONE inside my handleEvent() without success (my own event handler works, but also the tray is opened).

I also tried to override openTray() to do nothing, but then a NPE is thrown:

java.lang.NullPointerException
    at org.eclipse.help.ui.internal.DefaultHelpUI.displayContextAsHelpTray(DefaultHelpUI.java:426)
    at org.eclipse.help.ui.internal.DefaultHelpUI.displayContext(DefaultHelpUI.java:348)
    at org.eclipse.help.ui.internal.DefaultHelpUI.displayContext(DefaultHelpUI.java:288)
    at org.eclipse.ui.internal.help.WorkbenchHelpSystem.displayContext(WorkbenchHelpSystem.java:905)
    at org.eclipse.ui.internal.help.WorkbenchHelpSystem$WorkbenchHelpListener.helpRequested(WorkbenchHelpSystem.java:142)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:153)
    ...

Any ideas? I'm using Eclipse Kepler.

Upvotes: 1

Views: 156

Answers (1)

leonbloy
leonbloy

Reputation: 75926

Well, I found a way. I'm not sure if it's the recommended/clean/safe way, but in case it helps someone, this worked for me:

@Override
protected void configureShell(Shell shell) {
    super.configureShell(shell);
    shell.addHelpListener(new HelpListener() {
        @Override
        public void helpRequested(HelpEvent e) {
            // nothing to do
        }
    });
}

Upvotes: 1

Related Questions