(This has come up before, but I think it merits rehearsal)
Many OmniFocus applescripts need to read the current selection(s) in the sidebar or content panels.
The fastest and programmatically simplest way of doing this is currently hampered by the fact that the values returned by item nodes (Grouping dividers like "Due more than a year ago" "Inbox" etc) have not been given ANY properties at all ...
A name property would be enough to make a large difference ...
Select a grouping divider in the contents panel, and you will be able to see the information loss by running the following ...
(The only property of the value of a grouping node in the tree turns out to be its class ...)
RESULT: 'cobj'{ }
This is a pity, because this information loss forces us back to the slower and clumsier of the following two approaches:
Many OmniFocus applescripts need to read the current selection(s) in the sidebar or content panels.
The fastest and programmatically simplest way of doing this is currently hampered by the fact that the values returned by item nodes (Grouping dividers like "Due more than a year ago" "Inbox" etc) have not been given ANY properties at all ...
A name property would be enough to make a large difference ...
Select a grouping divider in the contents panel, and you will be able to see the information loss by running the following ...
(The only property of the value of a grouping node in the tree turns out to be its class ...)
Code:
tell application "OmniFocus" tell content of front window to return properties of value of first selected tree where class of its value is item end tell
This is a pity, because this information loss forces us back to the slower and clumsier of the following two approaches:
Code:
-- RETRIEVE VALUE OF EACH TREE NODE ONE BY ONE -- SLOW ENOUGH TO IRRITATE ... needs 582 Apple Events on my system today ... tell application "OmniFocus" tell front window repeat with oTree in (selected trees of content) set oValue to value of oTree -- process oValue end repeat end tell end tell
Code:
-- GET WHOLE VALUE LIST IN ONE EVENT ... -- FAST ... always needs just one Apple Event ... -- (imperceptible 5/100 of a second) tell application "OmniFocus" tell front window repeat with oValue in (value of selected trees of content) as list -- process oValue end repeat end tell end tell
Last edited by RobTrew; 2011-06-27 at 02:17 AM..