1 Reply Latest reply: Apr 3, 2010 7:50 AM by Pierre L.
Boberino Level 1 (30 points)
This would seem like a simple issue, and it may well be, but I am stumped.

In Pages, I have a document with some text on it, say "Hello World"
The cursor is at the end of the sentence, blinking. (No return after "Hello World")
I want to insert a return and have the cursor end up sitting after that return, (blinking).

I have tried this with limited results:

tell application "Pages" to tell document 1
set mySel to (get selection)
set selection to mySel & return
end tell

The problem here is that while this does insert a return after "Hello World", the selection is still at the end of "Hello World"

Consequently, if I were to start typing, the new text would be at the end of paragraph 1, and not at the end of paragraph 2.

All I am trying to do is insert a new paragraph at the cursor and begin inserting text from there.

Any help is greatly appreciated.

Mac Pro, Mac OS X (10.6.3)
  • Pierre L. Level 5 (4,255 points)
    Both of the scripts below should insert a return character before the insertion point:

    --Script 1
    *tell application "Pages" to tell document 1*
    *set P to character offset of (get selection)*
    *make new character at before character P with data return*
    *select insertion point after character P*
    *end tell*

    --Script 2
    *tell application "Pages" to activate*
    *tell application "System Events" to keystroke return*