white_pawn
white_pawn

Reputation: 205

Showing/hiding a SWT Menu at runtime

I'm trying to dynamically show/hide (or create/dispose) a SWT Menu (via JFace MenuManager) at runtime, based on a simple event. More specifically, when a desired control is activated, I would like to show an additional menu in the menu bar. As soon as it's deactivated, the newly added menu should disappear. Something like this:

addListener(SWT.Activate, new Listener(){
    public void handleEvent(Event event) {
        showAdditionalMenuManager();
    }
});

addListener(SWT.Deactivate, new Listener(){
    public void handleEvent(Event event) {
        hideAdditionalMenuManager();
    }
});

The listeners definitely work, but I've tried both setVisible(), and disposing/recreating the menu (disposing gives results, recreating doesn't) with no luck. Any help would be much appreciated.

Upvotes: 1

Views: 1554

Answers (1)

Tonny Madsen
Tonny Madsen

Reputation: 12718

Hmm, I suspect that the parent menu manager is not properly updated... there are no automatics here... You must call parent.updateAll(true) on the parent as well. And possibly parent.remove(additionalMenuManager) first.

Upvotes: 1

Related Questions