0
votes

Im using a mx:MenuBar component with xml data to bring a menu. The basic behaviour as I see is, initially on clicking the top level menu item (i.e on the horizontal bar), the pop-up sub menu opens. Then without clicking anywhere, if I mouse over / roll over on the horizontal menu bar, the pop-up sub menus of the other top level menus opens up.

This behaviour seems to be inconsistent. The pop-up sub menus should open either on click of any top level menu item (horizontal menu bar) or only on mouse over / roll over of the menu bar items.

I want the pop-up submenus to open only on click of the top level menu (horizontal menu bar). So I added event handlers for mouseOver as well as rollOver events (don't know which event actually gets generated on hovering over the horizontal menu bar). In the event handlers, I called the event.preventDefault() method to prevent the default behaviour(i.e opening of pop-up sub menus). But, nothing works. I felt like, I don't have control over it.

Could anyone say how to suppress the default behaviour and open the pop-up submenus only on click event of the menu bar.

1
Why do you think this behaviour incosistent? This is the same behaviour of the windows programs.HugoLemos
Thanks for your reply. Ok. The menubar may have the default behaviour as we see. But, If I want my menubar to open the pop-up submenus to open only on clicking any item in the menubar, How can I achieve it ?Santhosh Madhavaraj
Maybe you should create a new actionscript class extending MenuBar and override the handlers. See a example: livedocs.adobe.com/flex/3/html/…HugoLemos

1 Answers

0
votes

You could use "monkey patching" to redefine the behaviour of the MenuBar class. It is not easy to do it through overriding of the methods, because they are private.

Here is a working example with an active "view source" property.

The function to be rewritten is

private function mouseOverHandler(event:MouseEvent):void
{
}

One should delete the code lines, which activate a new menu.