Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Working with selection in iWork Pages '09

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)

Posted on Apr 2, 2010 10:37 PM

Reply
Question marked as Best reply

Posted on Apr 3, 2010 7:50 AM

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*
1 reply
Question marked as Best reply

Apr 3, 2010 7:50 AM in response to Boberino

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*

Working with selection in iWork Pages '09

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.