Hello
I'm a bit annoyed with Pages.
If the selection is made of two different strings of text,
I may grab several useful infos with this trick :
tell application "Pages" to tell document 1 set theSel to get the selection try theSel * 1 on error errmsg log errmsg end try end tell
which return this log :
tell application "Pages" get selection of document 1 {text from character 209 to character 210 of body text of document id 10302510, text from character 222 to character 223 of body text of document id 10302510} (*Impossible de transformer {text from character 209 to character 210 of body text of document id 10302510 of application "Pages", text from character 222 to character 223 of body text of document id 10302510 of application "Pages"} en type number.*) end tell
or
tell application "Pages" get selection of document 1 {text from character 30 to character 31 of object text of shape 1 of foreground layer of page 2 of document id 5462874, text from character 39 to character 40 of object text of shape 1 of foreground layer of page 2 of document id 5462874} (*Impossible de transformer {text from character 30 to character 31 of object text of shape 1 of foreground layer of page 2 of document id 5462874 of application "Pages", text from character 39 to character 40 of object text of shape 1 of foreground layer of page 2 of document id 5462874 of application "Pages"} en type number.*) end tell
or
tell application "Pages" get selection of document 1 {text from character 26 to character 27 of object text of text box 1 of foreground layer of page 2 of document id 5462874, text from character 32 to character 33 of object text of text box 1 of foreground layer of page 2 of document id 5462874} (*Impossible de transformer {text from character 26 to character 27 of object text of text box 1 of foreground layer of page 2 of document id 5462874 of application "Pages", text from character 32 to character 33 of object text of text box 1 of foreground layer of page 2 of document id 5462874 of application "Pages"} en type number.*) end tell
which may be easily deciphered with a bit of trickery.
Alas, when the selection is a single chunck of text, if grabbing the properties of the selection, I may know that it sits in a given page that it starts at character offset x (in a container which is not reported) that it contains contents and that it's length is, what a surprise, length of the contents.
But I found no way to grab the infos about the container which may be : body text of or object text of shape x of foreground layer of or object text of text box y of foreground layer of
At least from my point of view, the problem is that when the selection is a single object, get selection doesn't return a selection's descriptor but the selection's contents, and get a reference to the selection behaves the same.
I think that a logical behaviour would be:
get the selection returns a description and get contents of the selection returns … the contents
which is the real behaviour when several objects are selected.
I wish to know your advice before filing a bug report.
Yvan KOENIG (VALLAURIS, France) vendredi 2 avril 2010 19:30:11
|