6 Replies Latest reply on Feb 15, 2009 1:03 AM by Harbs.

    Own parent

    Level 1
      We all know that the InDesign application object is its own parent, but can anyone identify another object that can be its own parent?

      I stumbled on this by accident the other day.

      Just to be clear, I'm not talking about an object of a similar kind being the parent, for example, a rectangle can contain some other rectangle, I'm talking about an object which is its own parent.

      Hint: even though what I've said is true, if you happen to pass one of these objects to the findPage/findWhere functions we've been playing with lately, you'll not be dumped into an endless loop. [Huh! How is that possible?]

      Dave
        • 1. Re: Own parent
          Harbs. Level 6
          Hmm.

          That's a really good riddle!

          The only object I could think of that fits the clue is Character. Sure
          enough Character is listed in the OMV under the possible parents of a
          Character. Under what situation that can happen? I've no idea... =-O

          --
          Harbs
          http://www.in-tools.com
          • 2. Re: Own parent
            Level 1
            You're on the right track, but it's not character (nor any text object). The parent of a character is always the story (or XMLStory).

            Dave
            • 3. Re: Own parent
              Level 1
              What do you know, I've just found two other related objects that have the same characteristic. They can be their own parent -- by which I mean, if you ask for:

              myObj.parent

              the object you get is myObj. Even to the extent that:

              myObj.parent == myObj

              returns true.

              Dave
              • 4. Re: Own parent
                Harbs. Level 6
                Okay. So when is a Cell its own parent?

                --
                Harbs
                http://www.in-tools.com
                • 5. Re: Own parent
                  Level 1
                  That's it.

                  myCell = myTable.cells[0];
                  myOtherCellRef = myCell.cells[0];
                  myOtherCellRef == myCell; returns true

                  but

                  myOtherCellRef.parent == myCell; also returns true

                  same thing happens with rows (and I assume columns).

                  I suspect that it has something to do with the fact that you can reference sets of cells or it could just be an accidental thing.

                  myCell = myTable.cells[0].cells[0].cells[0].cells[0];

                  also works and gives you the same cell and if you work your way up the parental chain it takes you four steps to get to the table.

                  Dave
                  • 6. Re: Own parent
                    Harbs. Level 6
                    Very interesting!

                    The same basic concept applies to text objects. A
                    Character.characters[0].characters[0], etc. will always be the same
                    object. It only works down the parent chain. If you work up the chain,
                    the immediate parent will be the story.

                    I think the fact that it works down the chain is probably a feature
                    (i.e. if you do a search you can refer to characters[0] no matter what
                    the search returns -- even a Character). The fact that cells work up the
                    chain is probably a bug...

                    --
                    Harbs
                    http://www.in-tools.com