• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting Pages Insertion point (was Setting TextEdit S( )
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting Pages Insertion point (was Setting TextEdit S( )


  • Subject: Re: Setting Pages Insertion point (was Setting TextEdit S( )
  • From: Axel Luttgens <email@hidden>
  • Date: Thu, 27 Sep 2007 10:23:54 +0200

On 27/09/07 0:22, Shane Stanley wrote:
On 26/9/07 10:47 PM, "KOENIG Yvan" <email@hidden> wrote:

So, it sounds as if "Insertion point" is a kind of synonym for
"Selection".
Am'I right ?

No, definitely not.

You _can_ select an insertion point if you click between two characters. You
can also refer to, for example, "insertion point 2", which refers to the
point after the first character and before the second, regardless of the
selection. It has nothing to do with the selection property.

Well, maybe are you both right... ;-)

Having a look at the dictionary of Pages 2:

    application n [inh. application; see also Standard Suite] : The Pages
        application.
        [...]
        selection (selection-object) : The current selection in the frontmost
            document.

    document n [inh. document; see also Standard Suite] : A Pages document.
        [...]
        selection (selection-object) : The current selection or insertion point.
        [...]

    selection-object n [inh. item] : A way to refer to the state of the current
        of the selection. Use the "select" command to make a new selection.

        PROPERTIES
        contents (anything) : The information currently selected. Use "contents
        of selection" to get or change information in a document.

So, it looks like Page's scripting model closely follows the GUI behavior.
In a document, one has either an insertion point or a selection, which is exactly what's happening when clicking/dragging in a document.
Moreover, from the application's point of view, there is one "active" selection or insertion point a a time: the one in the frontmost document.
The problem is that "selection" in the dictionary may be somewhat confusing; but the confusion is a limited one, as soon as one notices that "selection" appears nowhere else in the dictionary: it is just the way to access that GUI artefact that is either a blinking vertical bar or grayed portion(s) of text in a document.

Let's try a small experiment.
In Pages, create a blank document and just type "one two three".
In Script Editor, prepare following script:
    tell application "Pages"
        selection
        class of selection
        contents of selection
    end tell

Now, in Pages, click after "two" and run the script again:
    tell application "Pages"
        get selection
            insertion point before character 8 of body text of document "Sans titre"
        get class of selection
            insertion point
        get contents of selection
            ""
    end tell

Then, double-click "two" in Pages and run the script; in the log:
    tell application "Pages"
        get selection
            text from character 5 to character 7 of body text of document "Sans titre"
        get class of selection
            text
        get contents of selection
            "two"
    end tell

Finally, double-click "one" and command-double-click "three", then run the script:
    tell application "Pages"
        get selection
            {text from character 1 to character 3 of body text of document "Sans titre", text from character 9 to character 13 of body text of document "Sans titre"}
        get class of selection
            text
        get contents of selection
            {"one", "three"}
    end tell


HTH,
Axel
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Setting Pages Insertion point (was Setting TextEdit S( )
      • From: Shane Stanley <email@hidden>
References: 
 >Re: Setting Pages Insertion point (was Setting TextEdit Š ) (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Adobe InDesign CS2 - Anchored Text Frame
  • Next by Date: Re: Setting Pages Insertion point (was Setting TextEdit S( )
  • Previous by thread: Re: Setting Pages Insertion point (was Setting TextEdit Š )
  • Next by thread: Re: Setting Pages Insertion point (was Setting TextEdit S( )
  • Index(es):
    • Date
    • Thread