10 Replies Latest reply on Dec 10, 2008 11:53 AM by wrkoch

    List vs ItemRollOver event

    wrkoch
      I'm converting some Flex 1.5 code to Flex 3. In Flex 1.5 I had a list box with the following properties:

      <mx:List id="EntryQCodeList" rowHeight="16" rowCount="10"
      itemRollOver="QCodeDesc.text = EntryQCodeList.dataProvider.getItemAt(event.Index).QDESCRIPTION"
      itemRollOut="QCodeDesc.text=''" />

      Whenever I would roll over a list item, QCodeDesc would change. No worries

      In Flex 3 I have (changed event.Index to event.RowIndex):

      <mx:List id="EntryQCodeList" rowHeight="16" rowCount="10"
      itemRollOver="QCodeDesc.text = EntryQCodeList.dataProvider.getItemAt(event.rowIndex).QDESCRIPTION"
      itemRollOut="QCodeDesc.text=''" />

      The itemRollOver only works on the first item in the list the mouse rolls over, regardless of whether I move to a different item while in the list. If I remove the rowHeight property, the list works properly. If I increase the rowHeight value at some point the itemRollOver event starts firing.

      Why doesn't the event fire?
        • 1. Re: List vs ItemRollOver event
          rtalton Level 4
          The event works fine in this example:
          • 2. Re: List vs ItemRollOver event
            wrkoch Level 1
            Well you are right (events are firing) but... I adjusted the code slightly to force a row height change and tried various iterations of it. Figured out that it is the itemRollOut that is causing the issue. The events are firing but it appears the rollout is clearing the text -- the events are stepping on each other. I'm thinking there must be some sort of fixed height "hit"area. Guess I'll have to figure out a different way to clear the text.
            • 3. Re: List vs ItemRollOver event
              wrkoch Level 1
              OK - did some more checking and found a repeatable problem. The events are firing but when you make the rowheight smaller than the default, it fires the itemRollOut event even though you haven't rolled off the item I suspect a hit area calculation problem. It gets even more pronounced at very small row heights -- even the item highlight is off.

              Is there some other way to control the spacing between List elements without using rowheight?
              • 4. Re: List vs ItemRollOver event
                Level 7

                "wrkoch" <webforumsuser@macromedia.com> wrote in message
                news:ghotms$8s7$1@forums.macromedia.com...
                > OK - did some more checking and found a repeatable problem. The events
                > are
                > firing but when you make the rowheight smaller than the default, it fires
                > the
                > itemRollOut event even though you haven't rolled off the item I suspect a
                > hit
                > area calculation problem. It gets even more pronounced at very small row
                > heights -- even the item highlight is off.
                >
                > Is there some other way to control the spacing between List elements
                > without
                > using rowheight?

                Why not just use a custom itemRenderer and draw in a transparent background
                for a hit area? You may also need to set mouseEnabled on the label to
                false.

                HTH;

                Amy


                • 5. Re: List vs ItemRollOver event
                  wrkoch Level 1
                  I was looking into that a bit but I was hoping to avoid that. A lot of my data is in objects as opposed to this simple case. That means a custom renderer for each list just to tie the data in. And I can't use the LabelFunction. I don't like having to hack around something that is beginning to appear to be a bug. I may get to that point...
                  • 6. Re: List vs ItemRollOver event
                    rtalton Level 4
                    If you made a custom itemRenderer, as Amy suggests, it could be in a simple MXML file, and you could use it anywhere in your application. Any List or DataGrid component can be set to use it like this:
                    <mx:DataGrid>
                    <mx:columns>
                    <mx:DataGridColumn itemRenderer="myCustomItemRenderer" headerText="Column 1" dataField="col1"/>
                    <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
                    <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
                    </mx:columns>
                    </mx:DataGrid>

                    Look in the help docs and you will see how easy it is:
                    http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_7.html
                    • 7. Re: List vs ItemRollOver event
                      wrkoch Level 1
                      I would agree if everything was in the Label/Data format. But when you don't have that pattern, for every single different data element (or label function) you need a new custom renderer. I was hoping for something a bit more universal to overcome this bug.
                      • 8. Re: List vs ItemRollOver event
                        Level 7

                        "wrkoch" <webforumsuser@macromedia.com> wrote in message
                        news:ghp438$gg0$1@forums.macromedia.com...
                        >I would agree if everything was in the Label/Data format. But when you
                        >don't
                        > have that pattern, for every single different data element (or label
                        > function)
                        > you need a new custom renderer. I was hoping for something a bit more
                        > universal to overcome this bug.

                        No, if you implement IDropInListItemRenderer, you can get access to which
                        property of the object that you've gotten is the one you're supposed to
                        render (hint: listData contains the pieces you need to figure this out).
                        That's how the built-in renderers are able to do what they do when you
                        specify a dataField--usually they just look at listData.label, which will
                        contain the text of the dataField or the return of the labelFunction.

                        HTH;

                        Amy


                        • 9. Re: List vs ItemRollOver event
                          rtalton Level 4
                          I think you are trying to accomplish two things here:
                          1) Display List data in a TextArea and Label, and,
                          2) Change the rowHeight property on that item in the List.
                          And you are using the itemRollOver/Out events to do both.
                          Is this correct?

                          If so, can you tell us what the rowHeight change is needed for?
                          I can see why changing the rowHeight triggers the itemRollOut event, so I'm wondering if there's another way of accomplishing what you want without using an itemRenderer at all.
                          • 10. Re: List vs ItemRollOver event
                            wrkoch Level 1
                            Rtalton - I orginally tried to have data in a label based on the list element. The text area was a diagnostic to tell me what events were firing when. I am not changing rowheight dynamically. I had been using the itemRoll Over/Out event in flex 1.5 to set the label text. I just used a smaller row height to pack more data into the list. Worked exactly the way I thought it should. The improper triggering of the itemRollOut event in Flex3 was a complete shock. I expected backwards compatibility and didn't get it.

                            Amy, I will have to look into the custom renderer some more and do some learning. Obviously you are way smarter in this area than I. I haven't done anything that involved with renderers (yet).