Hi all,

I'm tinkering with a menubar and a toolbar. I am attempting to
centralize the enabling and disabling of functionality based on the
application's state, and I am using the ModelLocator from the cairngorm
best practices to achieve this.

At present I have a number of functionality items that appear both on
the text "MenuBar" and the icon-based Toolbar. I am able to manage a
boolean "enabled" state variable for each action, but would like this
variable to be used in the definition of a MenuBar.

I have a feeling that the manner in which I create the data for the
MenuBar might be hindering my data binding efforts on the MenuItems.
Note that in this example, when I use the text values "true" and
"false", they are enabled and disabled appropriately. However, when
attempting to use data binding, they all remain enabled despite being
set to Boolean false.

Here is "MyMenuBar.mxml"
Any thoughts and ideas are appreciated.

Regards,
Graham Weldon

==================================================================================================
<mx:MenuBar
    xmlns:mx="http://www.adobe.com/2006/mxml"
    dataProvider="{menuXML}"
    labelField="@label">
  
    <mx:Script>
        <![CDATA[
      
            import mx.collections.XMLListCollection;
      
            [Bindable]
            private var rawMenuXML : XMLList =
            <>
                <menuItem
                    label="File"
                    enabled="true">

                    <menuItem
                        label="New..."
                        enabled="false"/>
                    <menuItem
                        label="Open..."
                        enabled="true"/>
                    <menuItem
                        label="Close"
                        enabled="false"/>
                    <menuItem
                        label="Close All"
                        enabled="true"/>
                    <menuItem
                        label="Save"
                        enabled="false"/>
                    <menuItem
                        label="Save As..."
                        enabled="{MyModelLocator.getInstance().SAVE_AS}"/>
                    <menuItem
                        label="Save All"
                        enabled="{MyModelLocator.getInstance().SAVE_ALL}"/>

                </menuItem>
            </>
            ;
          
            [Bindable]
            private var menuXML : XMLListCollection = new
XMLListCollection(rawMenuXML);
        ]]>
    </mx:Script>
  
</mx:MenuBar>
==================================================================================================




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




YAHOO! GROUPS LINKS




Reply via email to