Hi Jeff –

 

MenuBar.getMenuAt() returns a reference to a Menu. getMenuAt() is a method on MenuBar and menuItems is a property on MenuBar, which is why you encounter the errors below when you try to use those APIs on a Menu.

 

Since Menus are dynamically created as needed, there is a possibility a nested child menu has not been created yet. As menus get created, MenuBar adds those menus to its ‘menus’ array. ‘menus’ is a handy array that stores Menus created for that MenuBar control and you might find that handy for your needs.

 

If you can’t guarantee that the menus have been created but you still want to walk your MenuBar, you can go at it from a data-centric point of view. You can use the MenuBar’s dataDescriptor to walk the MenuBar’s data looking for children (hasChildren(), getChildren() will be handy) at each node. If children exist, you know that node has a sub-menu.

 

One last thing – it looks like your original question was how to disable menu items. Since disabling/enabling is a data-driven functionality (all you need to do is toggle the enabled property) you can do it through the data bound to the MenuBar instead of walking the MenuBar’s individual Menus and sub-Menus. For example, you can use e4x to access the node you want to disable in the MenuBar dataProvider and set the enabled attribute to false and boom, your MenuBar will show that menu item as disabled without any extra work. Or, you can go at it through your MenuBar’s dataDescriptor and find the node you want to disable and use IMenuDataDescriptor.setEnabled() to disable that node.

 

HTH –

deepa

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of jeff tapper
Sent: Monday, August 21, 2006 12:34 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Disabling a nested menu item in a menu bar?

 

Sadly, thats where the problems started for me. I'm able to get at
the top level items, using getMenuAt or even using the menuItems
array, but sadly, i cant seem to get a handle on the first child menu

var myMenu:MenuBar = myMenuBar;
var nextLevel:* = myMenu.getMenuAt(0);

// throws error Property menuItems not found on mx.controls.Menu
var firstNestedChild:* = nextLevel.menuItems;

// throws error (Property getMenuAt not found on mx.controls.Menu)
var firstNestedChild:* = nextLevel.getMenuAt(0);

so, coming back to the original question, what syntax can i use to
get a handle on the nested children MenuBarItems?

--- In [EMAIL PROTECTED]ups.com, "Tim Hoff" <[EMAIL PROTECTED]> wrote:
>
> Bummer - sorry,
>
> Probably need to look at MenuBar.getMenuAt(index).
>
> -TH
>
> --- In [EMAIL PROTECTED]ups.com, "jeff tapper" <jeff@> wrote:
> >
> > unfortunately not, its populated dynamically at run time. Any
> other
> > ideas on how to address a nested child of the menu?
> >
> > --- In [EMAIL PROTECTED]ups.com, "Tim Hoff" <TimHoff@> wrote:
> > >
> > >
> > > Hi Jeff,
> > >
> > > You can handle this with binding. Something like this:
> > >
> > > <menuItem label="File" enabled="{model.FileMenuEnabledFlags
(0)}">
> > > <menuItem label="New" enabled="{model.FileMenuEnabledFlags
> > (1)}"/>
> > > <menuItem label="Open"
enabled="{model.FileMenuEnabledFlags
> > (2)}"/>
> > > <menuItem label="Save"
enabled="{model.FileMenuEnabledFlags
> > (3)}"/>
> > > </menuItem>
> > >
> > > model.FileMenuEnabledFlags is an array of Boolean values.
> > >
> > > -TH
> > >
> > > --- In [EMAIL PROTECTED]ups.com, "jeff tapper" <jeff@> wrote:
> > > >
> > > > Anyone have a clue how to disable a menu bar item, when it
is
> > not the
> > > > top level?
> > > >
> > > > Given a structure like this:
> > > > <menuItem label="File">
> > > > <menuItem label="New" />
> > > > <menuItem label="Open" />
> > > > <menuItem label="Save" />
> > > > </menuItem>
> > > >
> > > > I can easily get a handle on the root node ("File"), by
> accessing
> > > > myMenu.menuItems[0], however, i'm banging my head against
the
> > wall
> > > > trying to get a handle on Save as a MenuBarItem, as the File
> item
> > > > doesnt seem to have child items representing the others.
> > > >
> > > > Can someone point me in the right direction here?
> > > >
> > > > Thanks
> > > >
> > >
> >
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to