简体   繁体   中英

Show the submenu on mouse over instead of mouse click in MenuBar in Flex 4.6

I am working in Flex 4.6 web application. I have a menubar when i click on that submenu is being open after that it works on mouse over. Now the problem is I want it on mouse over when i over the mouse on menubar submenu should open not onclick. How can i do it. Please give me your advice.

Thanks Bikrant Singh

You can use MOUSE_OVER event this way

    <mx:MenuBar id="menuBar" creationComplete="onMenuComplete(event)" />



    private function onMenuComplete(event:FlexEvent) {
        menuBar.addEventListener(MouseEvent.MOUSE_OVER, onMenuRollOver, true);

    }

    private function onMenuRollOver(event:MouseEvent):void {
        if (event.target is IMenuBarItemRenderer && menuBar.selectedIndex == -1) {
            var index:int = IMenuBarItemRenderer(event.target).menuBarItemIndex;
            menuBar.selectedIndex = (index == 0) ? 1 : 0;
        }
    }

But if you want to hide it too, you should use MOUSE_OUT event

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM