Dealing With Selected Rows / Cells
I am playing with putting things into OO4 via applescript. Please note that I am new to apple scripting.
This script does more or less what I want: [CODE]tell application "OmniOutliner" set MyDoc to front document set myText to "Hello World!" -- set the note of selected row to myText set note of selected rows of MyDoc to myText -- set the cell of selected row to myText set topic of selected rows of MyDoc to myText set curRow to selected rows of MyDoc end tell[/CODE] Still, a few questions remain: - is it correct to set the "topic" of a row to the text (or is there another way) - in my current document, for a selected row, I get for example [CODE]{child 2 of child 1 of child 2 of document id "aGFw5TYjAVs" of application "OmniOutliner"}[/CODE] - this is wonderful, because this contains the number that I seem to need: 2+1+2, which is the ID of the current row, which I seem to need when I want to add an attachment (as the ID of the row in [URL="http://forums.omnigroup.com/showpost.php?p=129355&postcount=5"]this example script[/URL]) -- is this the way to get to this ID, or are there other ways? I played with [CODE]set rowInd to index of first selected row of myDoc set rowDepth to level of first selected row of myDoc[/CODE] but I wasn't successful. |
[QUOTE=Carlos;129508]
- is it correct to set the "topic" of a row to the text (or is there another way) [/QUOTE] Setting the "topic" is the simple way to get at the text of the cell in the topic column. You can also set the text of a specific cell: [CODE] set text of topic cell of first selected row to "Hello!" set text of cell "French" of first selected row to "Bonjour!"[/CODE] (Note that "topic cell" always accesses the cell in the topic column—no matter what it's named—while 'cell "French"' will access the cell in the column named "French".) [QUOTE]- this is wonderful, because this contains the number that I seem to need: 2+1+2, which is the ID of the current row, which I seem to need when I want to add an attachment (as the ID of the row in [URL="http://forums.omnigroup.com/showpost.php?p=129355&postcount=5"]this example script[/URL])[/QUOTE] Oh, sorry if my example led you astray! You don't need a specific id, you just need to tell the text of some cell that you want to make a new attachment. Here's an example of that which is based on your example: [CODE]set myAttachmentPath to "/Applications/OmniOutliner Pro.app/Contents/Resources/HelpImages/oo4mac_aboutbox.png" tell front document of application "OmniOutliner Pro" set targetCell to topic cell of first selected row set text of targetCell to "Hello, world! Here's an attachment: " tell text of targetCell make new file attachment with properties {file name:POSIX file myAttachmentPath, embedded:true} at end of characters end tell end tell[/CODE] As for the next question: [QUOTE]-- is this the way to get to this ID, or are there other ways?[/QUOTE] As you already found, "first selected row" will return "child 2 of child 1 of child 2 of document id…" when that's what you have selected. But there's nothing magic about that path of descendents; you can write those same words in your script instead of writing "first selected row". For example, in the above script you could replace the targetCell assignment with: [CODE] set targetCell to topic cell of child 2 of child 1 of child 2[/CODE] and you'd update that 2+1+2 cell every time (if it exists), ignoring the current selection. Hope this helps! |
All times are GMT -8. The time now is 03:22 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.