2 Replies Latest reply on Oct 24, 2011 4:58 AM by jeffreypritchard

    custom itemRenderer states

    jeffreypritchard

      Hi,

       

      I have a custom item renderer in a list, which has three states by default: 'normal', 'hovered', and 'selected. When put in the hover state (by a mouse over), a button appears (an 'edit' button), and this all works great. When the button is pressed, the renderer changes state to 'selected' which changes the state of the parent container to a 'details' view. The problem occurs when I'm done making my changes in the details view, and return to the list view. The renderer seems to be stuck in the 'selected' state (showing the 'edit' button while NOT hovered. Even hovering over the item renderer does not seem to have any effect on the item renderer's state.

       

      Am I missing something ? Is there an event that fires every time an item renderer is shown that can 'reset' it's state to normal ?. I hope I explained the situation well enough, although I'm not sure I have.

       

      Thanks in advance

        • 1. Re: custom itemRenderer states
          Shongrunden Adobe Employee

          The selected state takes precedence over the hovered state and there is no "hoveredAndSelected" state, for 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">

             

              <s:List>

                  <s:itemRenderer>

                      <fx:Component>

                          <s:ItemRenderer>

                              <s:states>

                                  <s:State name="normal" />

                                  <s:State name="hovered" />

                                  <s:State name="selected" />

                              </s:states>

                             

                              <s:Rect width="100%" height="100%">

                                  <s:fill>

                                      <s:SolidColor color.normal="green"

                                                    color.hovered="yellow"

                                                    color.selected="red" />

                                  </s:fill>

                              </s:Rect>

                             

                              <s:Label text="{data}" />

                          </s:ItemRenderer>

                      </fx:Component>

                  </s:itemRenderer>

                  <s:dataProvider>

                      <s:ArrayList>

                          <fx:String>0</fx:String>

                          <fx:String>1</fx:String>

                          <fx:String>2</fx:String>

                          <fx:String>3</fx:String>

                      </s:ArrayList>

                  </s:dataProvider>

              </s:List>

             

          </s:Application>

           

           

          You should be able to add that state to your ItemRenderer by overriding ItemRenderer.getCurrentRendererState().

          1 person found this helpful
          • 2. Re: custom itemRenderer states
            jeffreypritchard Level 1

            Thanks a lot,

             

            I got the result I needed by doing exactly that, overriding getCurrentRendererState().