• 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 22:55:01 +0200

On 27/09/07 15:54, KOENIG Yvan wrote:


[...]

Yes, view like that, scripting appears as a kind of puzzle.

How may I guess that the correct reference is

insertion point before character 12

while
insertion point 11 is a wrong one ?


Hmmm...
Perhaps by reading between the lines of the dictionary as well as with a lot of sweat... ;-)


This is what the dictionary says about class "insertion point":

insertion point n [inh. item] : location between two characters

ELEMENTS
contains characters, charts, graphics, images, insertion
points, lines, paragraphs, shapes, tables, text, text
boxes, words; contained by characters, insertion points,
paragraphs, text, words.

PROPERTIES
[...]

So, it appears that an insertion point isn't an element of a document nor of a document's body text; this one

tell application "Pages" to tell document 1
get properties of insertion point 12 of body text
end tell

should thus definitely be wrong (and indeed, it errors).

Now, according to the dictionary, a word (for example) may contain insertion points.
So, let's try an index reference form applied to a word:


tell application "Pages"
tell body text of front document
insertion point 1 of first word
end tell
end tell

It errors again.
In fact, one could have guessed the fact by trying:

tell application "Pages"
tell body text of front document
every insertion point of first word
end tell
end tell

It errors instead of returning a list of insertion points: there was thus no point to refer an insertion point by index.
After all, this is rather sensible when considering the volatility of such beasts (insertion points).
More generally, this would also mean that any reference form implying some kind of enumeration should fail; and indeed this one, for example:


tell application "Pages"
tell body text of front document
some insertion point of first word
end tell
end tell

fails the same way.

So, this leads us to relative reference forms, such as:

tell application "Pages"
tell body text of front document
insertion point before first word
end tell
end tell

But to be fair, one already had some hint through the definition itself, "location between two characters"...
An insertion point is thus defined in relationship to other objects, not as an absolute entity.



[...]

Shane's proposal

tell application "Pages"
tell document 1
set contents of insertion point after character 12 of body text to " truc "
end tell
end tell


don't send an error but does nothing ;-((


It errors here (with Pages 2), hence the "set text of insertion point..." I suggested in a previous post.

Once again, scripting Pages resemble to a puzzle.


I asked here before I was aked myself by a Pages user.
In fact at this time I'm mainly searching the oddities striking in localized Numbers.


Back to Pages, when I read in the dictionary:

insertion point n [inh. item] : location between two characters

I assumes that I may grab them or the items whose insertion points inherit.

get insertion points of body text

returns {missing value}


I think this is answered in the above.

while

get items of body text


Here too, the concept of "every item" as an ordered and countable set is somewhat problematic.
Moreover, "item" seems to be some kind of blueprint, not a way to designate true objects.


returns:
"Erreur dans Pages : Impossible de transformer every item of body text of document 1 en type reference."


So, I'm a bit annoyed.


If I understood you correctly, you are interested in the objects that surround the GUI insertion point (the blinking vertical bar).

The same way the dictionary says that a character (for example) contains insertions points, it says that an insertion point contains characters (or words, or paragraphs, or...).
It should thus be possible to reason the same way as above, but by considering now the insertion point as the central piece.
In which case something like this should make sense:


tell application "Pages"
tell front document
set S to selection
tell body text
properties of character before S
character before S
word after S
end tell
end tell
end tell

And... yes, it works (assuming of course the current selection is surrounded by characters and words).

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
References: 
 >Re: Setting Pages Insertion point (was Setting TextEdit S( ) (From: Shane Stanley <email@hidden>)
 >Re: Setting Pages Insertion point (was Setting TextEdit S( ) (From: KOENIG Yvan <email@hidden>)
 >Re: Setting Pages Insertion point (was Setting TextEdit S( ) (From: Axel Luttgens <email@hidden>)
 >Re: Setting Pages Insertion point (was Setting TextEdit S( ) (From: KOENIG Yvan <email@hidden>)

  • Prev by Date: Re: Adobe CS2 and CS3
  • Next by Date: Bad Character
  • Previous by thread: Re: Setting Pages Insertion point (was Setting TextEdit S( )
  • Next by thread: Re: Setting Pages Insertion point (was Setting TextEdit S( )
  • Index(es):
    • Date
    • Thread