views:

246

answers:

2

Hi there

I have a MenuBar which contains general menu items like File, View, Tools ,Help. I have sub items in each of those menuitems. The problem is that i want to open the 'File' menu automatically when i press Alt+f key. I could capture the keyevents on the view.

But how to open the File Menu of the MenuBar (what is the function that needs to be called from MenuBar Class to popup those sub menuitems) ? I have searched for some information on google .. but cudnt find. or else if u have any better solution or example ..plz do post it.

<root>
    <menuitem label="File">
        <menuitem label="New" enabled="false"/>
        <menuitem label="Open.." enabled="false"/>
        <menuitem label="Save" enabled="false"/>
        <menuitem label="Restore" enabled="false"/>
        <menuitem label="Print" enabled="true"/> 
        <menuitem type="seperator" enabled="false"/> 
        <menuitem label="Exit" enabled="true"/>    
    </menuitem> 
    <menuitem label="View" accesskey="v">
        <menuitem label="Zoom In" enabled="true" maxValue="200"/>
        <menuitem label="Zoom Out" enabled="true" maxValue="25"/>
    </menuitem>       
    <menuitem label="Tools" enabled="false">
        <menuitem label="item1" enabled="false"/>
        <menuitem label="item2" enabled="false"/>
    </menuitem> 

</root>

Thanks in advance :)

Sriss

A: 

I solved it :)

var fileMenu:Menu = myMenuBar.getMenuAt(0);

fileMenu.show();

It works, but now the problem is .. the submenu is popping out at (0,0) location of the application not at the file Menu item ..!!!

Sris
A: 

to open menu at its position :

var fileMenu:Menu = mnuBar.getMenuAt(0);

pnt : Point = new Point(mnuBar.x,mnuBar.y + mnuBar.height);

pnt = localToGlobal(pnt);

fileMenu.show(pnt.x,pnt.y);

EmersioN