Philip Mair created FLEX-33593:
----------------------------------

             Summary: mx.controls.MenuBar#mouseOutHandler TypeError
                 Key: FLEX-33593
                 URL: https://issues.apache.org/jira/browse/FLEX-33593
             Project: Apache Flex
          Issue Type: Bug
          Components: mx: Menu Bar
    Affects Versions: Apache Flex 4.9.0
            Reporter: Philip Mair


When changing MenuBar dataProvider within click on Menu sometimes causes a 
TypeError in mouseOutHandler.

I solved this with following workaround:

                public override function 
addChild(child:DisplayObject):DisplayObject
                {
                        if( child is IMenuBarItemRenderer )
                        {
                                var item: IMenuBarItemRenderer = 
IMenuBarItemRenderer( child );
                                
                                
                                item.addEventListener( MouseEvent.MOUSE_OUT, 
patchedMouseOutHandler, false, int.MAX_VALUE );
                        }
                        
                        return super.addChild( child );
                }
                
                private function patchedMouseOutHandler( event: MouseEvent ) : 
void
                {
                        //stop the event to avoid npe
                        event.stopImmediatePropagation();
                        event.stopPropagation();
                        
                        var item:IMenuBarItemRenderer = 
IMenuBarItemRenderer(event.target);
                        var index:int = item.menuBarItemIndex;
                        var m:Menu = getMenuAt(index);
                        
                        if (item.enabled && selectedIndex != index)
                        {
                                if( menuBarItems.indexOf( item ) >= 0 )
                                        menuBarItems[index].menuBarItemState = 
"itemUpSkin";
                        }
                        // Fire the appropriate rollout event
                        if (item.data && 
                                (m.dataDescriptor.getType(item.data) != 
"separator"))
                        {
                                var menuEvent:MenuEvent = new 
MenuEvent(MenuEvent.ITEM_ROLL_OUT);
                                menuEvent.index = index;
                                menuEvent.menuBar = this;
                                menuEvent.label = itemToLabel(item.data);
                                menuEvent.item = item.data;
                                menuEvent.itemRenderer = item;
                                dispatchEvent(menuEvent);
                        }
                }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to