loadMenuContent does not clean up child popup menus?

7 messages - 118 views

Hi,

I am not sure if this is a bug... in a TabFolder I am trying to load different menus when each TabItem is selected. Say there are two tabitems tab1 and tab2.  When tab1 is selected I used loadMenuContent to load the following (from a xml):

<screenFirstmenu>
        Options
        <menupopup>
            <menu>
            Submenu
                <menupopup>
                    <menuitem onAction="action1">item1</menuitem>
                    <menuitem onAction="action2">item2</menuitem>
                </menupopup>   
            </menu>
        </menupopup>
</screenFirstmenu>   

 

When tab2 is selected, loads:

 

<screenFirstmenu onAction="action3">
item3
</screenFirstmenu>

 

I was navigating from tab1 to tab2 and tab2's screenFirstMenu does not respond to onAction. I figured out this is because that tab1's screenFirstmenu had sub menu and menupopups which were not cleaned up/removed so that tab2's screenFirstMenu get confused. I tried to manually remove the submenu and menupopups using cleanUp() and remove(), but it did not work. Any idea on how and why?

Many Thanks!

 

Does the firstMenu label change from Options to item3 ?

thanks tofu...

Yes it changed to item3, but when I pressed the left button, instead of doing action3 the left menu changes into Select and the right menu changes into Cancel, as if it's expecting a submenu...

If I make tab1's menu flat without the submenu, everything works for tab2.

Hmm ... the problem might come from an expected popup = null; int he removeAll(..) method of the Menu class.

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.Widget#removeAll()
     */
    public void removeAll() {
        super.removeAll();
        if (popup != null) {
            popup.removeAll();
            popup = null;
        }
    }

How do I make the kuix Java library from the source code? I can make the change you suggested and try it...

thanks tofu you are right, I added the popup = null; and it works fine now...

 

 

I think you found it, but for other, read this page.