AppleScript questions
Nicholas Riley
njriley at uiuc.edu
Fri Aug 22 10:09:10 PDT 2003
On Fri, Aug 22, 2003 at 11:59:48AM -0400, James Spahr wrote:
> tell application "OmniOutliner"
> tell document 1
> set theRow to the selected row
> set the topic of theRow to "bar"
> set the selected row to the first parent of theRow
> set the selected row to theRow
> end tell
> end tell
>
> (yea, a bit of a hack)
I figured out that simply repeating 'set the selected row to theRow'
twice fixes the problem without requiring a parent. This is certainly
a bug.
> tell application "OmniOutliner"
> tell document 1
> set theRow to the selected row
> set theParent to the first parent of theRow
> set theChildren to the children of theParent
>
> set newRow to make new row at the end of the children of
> theParent
> set the topic of newRow to "bar"
>
> move newRow to after theRow
>
> end tell
> end tell
Wonderful. The only problem I can't figure out is how to select the
new row once it's been moved. The row doesn't stay selected, and
since I still can't figure out how to extract the row indices, I'm stuck.
> >- The font of any script-set topic is Helvetica.
>
> I'm not seeing this. my script set topics follow the style guidlines
> for the outline. So I can not help you here.
Thanks for your help. The Helvetica thing is still happening for me,
on two different Macs with two different OS versions and OmniOutliner
2.2.3. Guess I should report it as a bug (how do you do that for Omni
software?)
Here's a version of the script which should work no matter what state
the outline is in. It would certainly be nice if it were easier to
do this!
tell front document of application "OmniOutliner"
local theDate, theRow
set theDate to (do shell script "date '+%A, %e %B %Y'")
set theRow to selected row
if not (exists selected row) then
set selected row to make new row at end of children of root with properties {topic:theDate}
else if theRow's topic is "" then
set theRow's topic to theDate
set the selected row to theRow
set the selected row to theRow
else
local theParent, newRow
try
set theParent to theRow's first parent
on error
set theParent to root
end try
set newRow to make new row at end of children of theParent with properties {topic:theDate}
move newRow to after theRow
end if
end tell
--
=Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
More information about the OmniOutliner-Users
mailing list