3 Replies Latest reply on Mar 14, 2008 3:19 AM by TNT Type

    Move the insertion point?

    Level 1
      Just when I think I'm starting to get this . . .

      How the blankety-blank-blank to I simply move the insertion point to the next line whether it be within the same paragraph or not, like hitting a down arrow key?!?!

      Thanks
        • 1. Re: Move the insertion point?
          Level 1
          That's a strange thing to want to do in a script. You're going to have to use the horizontal offset of the current insertion point to work out where in the next line to move the insertion point.

          For example, you might use these techniques:

          myIP = app.selection[0];
          if (myIP.hasOwnProperty("baseline") {
          // we have a text selection
          myNextLine = myIP.lines[0].insertionPoints[-1].lines[0];
          myHO = myIP.horizontalOffset;
          nextHOs = myNextLine.insertionPoints.everyItem().horizontalOffset;
          for (var j = 0; nextHOs.length > j; j++) {
          if (nextHOs[j] > myHO) {break}
          }
          app.select(myNextLine.insertionPoints[j]);
          }

          I'm 3,000 miles away from my InDesign installations at the moment so I can't test that, but it'll sort of work. It the next line is on the next page, you'll be in trouble, and if there's a text wrap or something, you might end up at the start of the line after next. But this should give you the idea, assuming, that is, that you want to use JavaScript.

          Dave
          • 2. Re: Move the insertion point?
            [Jongware] Most Valuable Participant
            I think Ken misunderstands the 'insertion point' name. It is not the position of the cursor, but more of an array of 'current' positions per character index. Each and every displayed character has an insertion point value; you can access this for each and every text refererring object (Story, Paragraph, Words, Lines, Characters, ... I'm sure I forgot a few).
            • 3. Re: Move the insertion point?
              Level 1
              Thanks a bunch guys. Dave that code makes perfect sense, even though I'm not in Java for this project and jongware you're exactally right, I was thinking backwards in terms of insertion point.

              Sigh . . . ever onward.

              Ken