简体   繁体   English

在运行时显示/隐藏SWT菜单

[英]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. 我试图基于一个简单事件在运行时动态显示/隐藏(或创建/配置)SWT菜单(通过JFace MenuManager)。 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. 侦听器肯定可以正常工作,但是我尝试了setVisible()和处置/重新创建菜单(处置产生了结果,重新创建了菜单)都没有运气。 Any help would be much appreciated. 任何帮助将非常感激。

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. 嗯,我怀疑父菜单管理器没有正确更新...这里没有自动parent.updateAll(true) ...您也必须在父菜单上调用parent.updateAll(true) And possibly parent.remove(additionalMenuManager) first. 并且可能是parent.remove(additionalMenuManager)首先。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM