2 Replies Latest reply on Nov 21, 2007 6:59 AM by totallyuniquescreenname

    menbar itemClick event

      Am i doing something wrong, or should cicking on the top level item in a menubar (one that does not have any children) not fire the itemClick event? I can't find any examples of menus that don't have children.
        • 1. Re: menbar itemClick event
          ntsiii Level 3
          This is a PITA behavior of menubar. The solution is to use the "click" event instead of the itemClick event. You reference the data provider Item in the handler like this:
          var oItem:Object = event.target.data;

          • 2. Re: menbar itemClick event
            totallyuniquescreenname Level 1
            here's how i made it work...
            <mx:MenuBar labelField="@label" dataProvider="{appMenu}" width="100%" click="menuHandler(event)" itemClick="submenuHandler(event)" />

            private function menuHandler(event:Event):void {
            if((event.currentTarget.selectedIndex !=-1) && XML(appMenu.getItemAt(event.currentTarget.selectedIndex)).children().length()<1){
            var item:XML = new XML(appMenu.getItemAt(event.currentTarget.selectedIndex));
            //Alert.show(String("Main Menu Label: "+item.@label+" Data: "+item.@data));
            private function submenuHandler(event:MenuEvent):void {
            //Alert.show(String("Sub Menu Label: "+event.item.@label+" Data: "+event.item.@data));