10 Replies Latest reply on Mar 16, 2009 9:12 AM by xfer_rdy

    How to get coordinates of FileSystemTree selected item ?

    xfer_rdy
      Hi can some one clue me in how to get the coordinates of the selected itwn in a FileSystemsTree ?

      thx

      -g
        • 1. Re: How to get coordinates of FileSystemTree selected item ?
          -Hob Level 1
          You would do something like this:

          var itemRenderer:DisplayObject = fileSystemTree.itemToItemRenderer(fileSystemTree.selectedItem) as DisplayObject;
          var coordinates:Point = itemRenderer.parent.localToGlobal(new Point(itemRenderer.x, itemRenderer.y));

          coordinates is now a point object representing the coordinates of your itemRenderer in the global coordinate system.
          • 2. Re: How to get coordinates of FileSystemTree selected item ?
            xfer_rdy Level 1
            Thanks Hob, you nailed it !!!

            Although the results were not what I was looking for, the width of the icons and text for the item.But, its a great first step. Thanks again

            -g
            • 3. Re: How to get coordinates of FileSystemTree selected item ?
              Level 7

              "xfer_rdy" <webforumsuser@macromedia.com> wrote in message
              news:gpehjl$3lb$1@forums.macromedia.com...
              > Thanks Hob, you nailed it !!!
              >
              > Although the results were not what I was looking for, the width of the
              > icons and text for the item.But, its a great first step. Thanks again

              On whatever event you're listening for to tell you something has happened in
              the itemRenderer, the currentTarget property will give you a reference to
              the renderer. Then just use e.currentTarget.measuredWidth and
              e.currentTarget.measuredHeight.

              HTH;

              Amy


              • 4. How to get coordinates of FileSystemTree selected item ?
                xfer_rdy Level 1
                Hi Amy,

                I'm listening on change for right now. This is a complicated 3 additions to the FileSystemTree. I'm adding a auto horizontal scroll (not changing the ctl width) so the selected item is always in view or mostly in view. Second same as the first, except the horizontal panning with item rollover. The mouse rollover has priority. Third, using the tool tip to expand the node name past the tree window when the mouse is rolled over the items.

                I find those features useful for "low function" users.

                -gary
                • 5. Re: How to get coordinates of FileSystemTree selected item ?
                  xfer_rdy Level 1
                  Hi Amy,

                  I tried your recommendation, unfortunately, its resulting in the same ambiguous measurement.
                  height: 158
                  width: 175

                  The name of the tree node is "karlheinz stockhausen"
                  The icons are either 16 or 32 p high. I'm not sure what the measurements mean.

                  -gary
                  • 6. Re: How to get coordinates of FileSystemTree selected item ?
                    Level 7

                    "xfer_rdy" <webforumsuser@macromedia.com> wrote in message
                    news:gpetqr$hfp$1@forums.macromedia.com...
                    > Hi Amy,
                    >
                    > I tried your recommendation, unfortunately, its resulting in the same
                    > ambiguous measurement.
                    > height: 158
                    > width: 175
                    >
                    > The name of the tree node is "karlheinz stockhausen"
                    > The icons are either 16 or 32 p high. I'm not sure what the measurements
                    > mean.

                    That will be the measurement of the entire itemRenderer. If you want to
                    measure things inside the renderer, you'll probably need to extend the
                    renderer to make that information public.

                    HTH;

                    Amy


                    • 7. Re: How to get coordinates of FileSystemTree selected item ?
                      xfer_rdy Level 1
                      Hi Amy,

                      Thanks,
                      I'm still confused about the dimensions. I can understand the width, it sort of is a believable number. The height, however, is6x greater than what I expect. Do you know how its derived ?

                      -gary
                      • 8. Re: How to get coordinates of FileSystemTree selected item ?
                        Level 7

                        "xfer_rdy" <webforumsuser@macromedia.com> wrote in message
                        news:gpgpur$k5f$1@forums.macromedia.com...
                        > Hi Amy,
                        >
                        > Thanks,
                        > I'm still confused about the dimensions. I can understand the width, it
                        > sort
                        > of is a believable number. The height, however, is6x greater than what I
                        > expect. Do you know how its derived ?

                        I believe the width property is the amount of space the List or tree or
                        whatever tells the component it is allowed to use, whereas measuredWidth is
                        the space the component tells the List or tree or whatever that its contents
                        should take up when properly laid out.


                        • 9. Re: How to get coordinates of FileSystemTree selected item ?
                          xfer_rdy Level 1
                          Hi,

                          That's sort of looks like what's happening, I'm going through the rendered hierarchy, I'll let you know what I find. When I get this working, I'll post the code.

                          -g
                          • 10. Re: How to get coordinates of FileSystemTree selected item ?
                            xfer_rdy Level 1
                            Hi Amy,

                            I looked at the code, this is the width calculation.

                            There are four (4) parts to each of the tree node display:
                            1) the indent, from _listData.indent Only value id _data is not null
                            2) the disclosureIcon.width
                            3) icon.measuredWidth
                            4) label measured or explicate width

                            The positions are calculated by:
                            1a) disclosureIcon.x = the indent
                            1b) disclosureIcon.setActualSize = disclosureIcon.width, disclosureIcon.height
                            2a) icon.x = the indent + disclosureIcon.width
                            2b) icon.setActualSize = icon.width, icon.height
                            3a) lable.x = the indent + disclosureIcon.width + icon.width
                            3b) lable.setActualSize = lable.width, lable.height

                            The label width:
                            label.width: the size of the visible portion of the label in the parent. It may be clipped/truncated.
                            label.textWidth: the total size of the text in the label

                            Maybe I can get the code finished today.

                            BTW, as I'm moving through this processes of learning flex, the one thing I've noticed is the lack of a concise MVC model or at least a breakout of the more complex UI components. I'd assume for such a strategic product, there would be more investment by Adobe in these technical areas. But, I guess its easier putting people on a bus and send them to city to city.



                            -g