5 Replies Latest reply on Apr 28, 2010 8:59 AM by -skitch-

    ButtonBar with no selection

    Zolotoj Level 3

      How can I make this control with no initial selection? I am using Flex 4.

       

      Thanks

        • 1. Re: ButtonBar with no selection
          Peter deHaan Level 4

          Are you using a Spark ButtonBar or MX ButtonBar control?

          I wasnt seeing a selection on either control with the following example:

           

          <?xml version="1.0" encoding="utf-8"?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                  xmlns:s="library://ns.adobe.com/flex/spark"
                  xmlns:mx="library://ns.adobe.com/flex/mx">
              
              <s:ButtonBar id="btnBar" horizontalCenter="0" verticalCenter="0">
                  <s:dataProvider>
                      <s:ArrayList source="[Red,Orange,Yellow,Green,Blue]" />
                  </s:dataProvider>
              </s:ButtonBar>
              
          </s:Application>

           

           

          Peter

          • 2. Re: ButtonBar with no selection
            Zolotoj Level 3

            This is my code:

            <s:ButtonBar id="tasks" requireSelection="true"> 
                 <s:layout>
                 <s:VerticalLayout gap="1"/>
                 </s:layout>
                 <s:dataProvider>
                 <s:ArrayCollection source="['Sewing', 'Cutting']" />
                 </s:dataProvider>
            </s:ButtonBar>
            

             

            Sewing button is highlighted.

            • 3. Re: ButtonBar with no selection
              -skitch- Level 1

              since you set RequireSelection = "true", you imply that something has to be selected...but you don't want anything selected on the initial view?

               

              You could always try something like changing the state of the view to update that posibility:

               

                  <s:states>
                      <s:State name="test1"/>
                      <s:State name="test2"/>
                  </s:states>
                 
                  <s:ButtonBar id="tasks"
                               requireSelection.test1="false"
                               requireSelection.test2="true"
                               click="{currentState='test2'}">
                      <s:layout>
                          <s:VerticalLayout
                              gap="1"/>
                      </s:layout>
                      <s:dataProvider>
                          <s:ArrayCollection
                              source="['Sewing', 'Cutting']" />
                      </s:dataProvider>
                  </s:ButtonBar>
              </s:Application>

              1 person found this helpful
              • 4. Re: ButtonBar with no selection
                Zolotoj Level 3

                I have set RequireSelection = "false" and now it comes up with no button selected.

                • 5. Re: ButtonBar with no selection
                  -skitch- Level 1

                  try it with the states...

                   

                  On the initial load you want - RequireSelection = false

                   

                  When one is clicked, you want RequireSelection = true

                   

                  using states, you can change the how a property is set.

                   

                  In my first state, I have requireselection = false

                  Once a click happens, I set the current state = state 2.

                  this makes requireselection = true.