4 Replies Latest reply on Nov 5, 2008 6:21 PM by jhuddle123

    AS CS3 - how to paste then select pasted text

    jhuddle123 Level 1
      Would love help with this:

      Part of my script will paste text. After pasting, I would like the script to then select the pasted text (so that it can proceed to apply a style sheet).

      How can I specify such a selection?

      Thanks.
        • 1. Re: AS CS3 - how to paste then select pasted text
          sstanleyau Level 4
          It would probably be easier to apply the styling to the insertion point<br />before the paste. But why are you pasting at all? There's rarely a need.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
          • 2. Re: AS CS3 - how to paste then select pasted text
            jhuddle123 Level 1
            Hi Shayne, thanks for responding.

            The larger goal for the script is to execute a kind of "paste without formatting" that preserves local formatting/overrides (itlas, bolds, character styles). The native feature does not support this.

            A designer will have live text, say, on the pasteboard, will copy the live text, then select a destination. The destination contains dummy text, formatted with the desired attributes. The live text needs to pick up the attributes and replace the dummy text, preserving overrides.

            The script creates a temporary style sheet capturing the destination attributes, pastes (which replaces the dummy text, putting the live text into position), applies the style sheet (giving the attributes but retaining overrides), then delete the temporary style. Of course as you're pointing out, the style sheet could be applied before pasting.

            If I'm thinking about this correctly, the problem is that the source text could have multiple paragraphs. Setting the insertion point with the desired attributes would take care of the first paragraph, but not the subsequent ones.

            any ideas?

            Meanwhile, if you can find an easy way to do this without copy/paste. . . that would be fantastic!
            • 3. Re: AS CS3 - how to paste then select pasted text
              sstanleyau Level 4
              You can get the information you need by getting the index of the insertion<br />point and length of the story before you paste. After you paste, you can<br />then refer to text from character insertionIndex to character insertionIndex<br />+ lengthAfter - lengthBefore.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
              • 4. Re: AS CS3 - how to paste then select pasted text
                jhuddle123 Level 1
                Shane, thanks for this  I'll try it out!