[ 
https://issues.apache.org/jira/browse/FLEX-33593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13687928#comment-13687928
 ] 

Philip Mair commented on FLEX-33593:
------------------------------------

On trying to provide a sample code i got an equal error in mouseOverHandler!

I think that all eventHandlers which are registered here:

MenuBar#insertMenuBarItem()

        item.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
        item.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
        item.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
        item.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);

should be removed in removeMenuBarItemAt(), and removeAll()
                
> 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
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> 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