RE: [flexcoders] Controlling MenuBar Submenus via Code frustrations
The menudatadescriptor has methods isToggled/get/setToggled, IIRC. Usually that maps to toggled properties or attributes in the dataprovider you sent to the MenuBar. Manipulating the data in the dataprovider is the recommended way of changing the state of the buttons. It is not recommended that you do it from the Menu instances as they can be created and destroyed dynamically. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mike Anderson Sent: Monday, October 29, 2007 1:15 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Controlling MenuBar Submenus via Code frustrations Greetings All, I've burned an entire DAY searching the web for examples of how to control sub-menus in a MenuBar control, via code. The main types of things I need to accomplish, is toggling Checkboxes and Radio Buttons, when certain application variables change. My MenuBar has 6 primary menus across the top, and each primary menu, could have any number of additional sub-menus (which have several variations of menu types - Checkboxes, Radio Buttons, etc.) My MenuBar is being populated via an external XML File. Per the docs, each top level menu is considered a 'MenuBarItem', but there is very little helpful information after that. All the help docs focus primarily on listening for MenuBar events and writing functions to respond - but there is NOTHING on how to do the reverse. I consider myself to be a fairly seasoned Flex Programmer, but this MenuBar stuff has got me stumped, and quite frustrated. If anybody has any examples on this topic, I would be VERY grateful. Thanks in advance for any help, Mike
[flexcoders] Controlling MenuBar Submenus via Code frustrations
Greetings All, I've burned an entire DAY searching the web for examples of how to control sub-menus in a MenuBar control, via code. The main types of things I need to accomplish, is toggling Checkboxes and Radio Buttons, when certain application variables change. My MenuBar has 6 primary menus across the top, and each primary menu, could have any number of additional sub-menus (which have several variations of menu types - Checkboxes, Radio Buttons, etc.) My MenuBar is being populated via an external XML File. Per the docs, each top level menu is considered a 'MenuBarItem', but there is very little helpful information after that. All the help docs focus primarily on listening for MenuBar events and writing functions to respond - but there is NOTHING on how to do the reverse. I consider myself to be a fairly seasoned Flex Programmer, but this MenuBar stuff has got me stumped, and quite frustrated. If anybody has any examples on this topic, I would be VERY grateful. Thanks in advance for any help, Mike
RE: [flexcoders] Controlling MenuBar Submenus via Code frustrations
Everything works through the dataProvider. First use e4x expressions to find the node you want to change, then set the attribute. Below are some lines from some of my code. I am only setting enabled and the label, but the same techniques should work for checkboxes, etc. Tracy public function set xmlSelectedItem(xml:XML):void { _xmlSelectedItem = xml; var sNodeName:String; var sActionType:String; var sAction:String; var sTemp:String = ; var sLabel:String = ; var xmlCopiedItem:XML; if (_xmlSelectedItem) { sNodeName = _xmlSelectedItem.name(); sActionType = [EMAIL PROTECTED]; sAction = [EMAIL PROTECTED]; xmlMenu..menuitem.(attribute(action) == 'deleteSelected')[EMAIL PROTECTED] = true; xmlMenu..menuitem.(attribute(action) == 'copySelected')[EMAIL PROTECTED] = true; xmlMenu..menuitem.(attribute(action) == 'addMenuItem')[EMAIL PROTECTED] = true; xmlMenu..menuitem.(attribute(action) == 'addAppItem')[EMAIL PROTECTED] = true; if (sNodeName == menu) { sTemp = to ' + [EMAIL PROTECTED] + ' } else { sTemp = to ' + [EMAIL PROTECTED] + '; } sLabel = Add Menu Item + sTemp; xmlMenu..menuitem.(attribute(action) == 'addMenuItem')[EMAIL PROTECTED] = sLabel; sLabel = Add Application Item + sTemp; xmlMenu..menuitem.(attribute(action) == 'addAppItem')[EMAIL PROTECTED] = sLabel; ... From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mike Anderson Sent: Monday, October 29, 2007 4:15 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Controlling MenuBar Submenus via Code frustrations Greetings All, I've burned an entire DAY searching the web for examples of how to control sub-menus in a MenuBar control, via code. The main types of things I need to accomplish, is toggling Checkboxes and Radio Buttons, when certain application variables change. My MenuBar has 6 primary menus across the top, and each primary menu, could have any number of additional sub-menus (which have several variations of menu types - Checkboxes, Radio Buttons, etc.) My MenuBar is being populated via an external XML File. Per the docs, each top level menu is considered a 'MenuBarItem', but there is very little helpful information after that. All the help docs focus primarily on listening for MenuBar events and writing functions to respond - but there is NOTHING on how to do the reverse. I consider myself to be a fairly seasoned Flex Programmer, but this MenuBar stuff has got me stumped, and quite frustrated. If anybody has any examples on this topic, I would be VERY grateful. Thanks in advance for any help, Mike