2013-09-13 2 views
0

Я пытаюсь сделать некоторые AppleScript-fu на страницах iWorks и хочу вставить текстовое поле в точке ввода документа WP. Согласно словарю для Pages есть объект, называемый точкой вставки, и он имеет элемент, называемый точкой вставки. Однако я ничего не могу получить:Страницы AppleScript - получить точку вставки

tell application "Pages" 
tell front document 

-->set properties for text box 
      set needs2Col to false 
      set colHeight to 0 
      if ((count of every item of headerFiles) > 5) then 
       set needs2Col to true 
       set boxH to (round ((count of every item of headerFiles)/2) rounding up) * (font size of bookMarkStyle) 
       set boxW to 6.5 * 72 
       set boxX to 72.0 
          -->all these crash and burn with can't get errors 
          return insertion point of insertion point 
          return bounds of last paragraph of body text 
          -->all these return missing value 
          return insertion point of last paragraph of body text 
       return insertion point of body text 
      end if 
end tell 
end tell 

Может ли кто-нибудь помочь мне здесь. Я просто ищу x/y точки вставки.

ответ

0

Вы можете использовать character offset of (get selection), чтобы получить начало выбора или местоположение точки вставки.

tell application "Pages" to tell document 1 
    --start of selection 
    character offset of (get selection) 

    --end of selection 
    tell (get selection) to character offset + length 

    --move the insertion point after the second paragraph 
    select insertion point after paragraph 2 

    --move the insertion point to the start of the second page 
    select insertion point before (paragraph 1 where page number of containing page is 2) 

    --replace the selected text 
    set selection to "aa" 

    --selection as plain text 
    contents of selection 
end tell 
Смежные вопросы