Results 1 to 2 of 2

Thread: Button menu-active style no longer added/removed on menu show/hide

  1. #1

    Default Button menu-active style no longer added/removed on menu show/hide

    When using TextToolItem on a toolbar, the -menu-active style is not set as it used to be in previous versions i.e. MyGwt.

    Here is what I found in my investigation...

    In the Button class there are 4 methods to do with showing and hiding menus.

    showMenu(), hideMenu(), onMenuHide() and onMenuShow().

    The onMenuHide and onMenuShow methods add and remove the -menu-active style accordingly. However it appears that these methods are never called any more.

    The showMenu method is called by GXT and appears responsible for showing the menu, etc. So an override of Buttons showMenu with an added call to onMenuShow() seems to deal with the style being set.

    Now to get the style to be removed I tried to override hideMenu(), however this method does not appear to be called at all. Instead Menu's are hidden with in the Menu class code. This code fires an Event of type "Hide".

    So a further override of the setMenu(Menu menu) method and adding a listener for the menu hide event, and subsequently callign onMenuHide() will allow the style to be removed.

    This -menu-active style was added and removed in MyGwt correctly, and doesn't appear to have worked in GXT 1.1.x (I have not tested versions in between).

    Is this a bug? if so I will post in the GXT bug forum, but I wanted to discuss it first to make sure.

    1) The main issue is that the -menu-active styles should be added to the button when the menu is visible and removed when not.
    2) It seems logical that the hideMenu() method in Button be removed, or the code changed to use it.
    3) If showing the menu is the Button's responsibility, shouldn't the Button also be responsible for hiding it? Or vice versa.. if the Menu is responsible for hiding, shouldn't the menu be responsible for showing itself as well? This should be made consistent.

    Here is the code that I ended up using to get it to add and remove the -menu-active style.

    class MenuTextToolItem extends TextToolItem {
            public ImpTextToolItem(String name) {
                this.button = new MenuButton();
        class MenuButton extends Button {
            public void showMenu() {
                if (menu != null) {
                    onMenuShow(null); // Param not used in base class method
            public void setMenu(Menu menu) {
                menu.addListener(Events.Hide, new Listener() {
                    public void handleEvent(BaseEvent be) {
                        onMenuHide(null); //Param not used in base class method

  2. #2


    Does anyone have any information about this? is it a bug? is it intentionally not set?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts