The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Values of 'item' nodes in sidebar/content trees have no properties (http://forums.omnigroup.com/showthread.php?t=21468)

RobTrew 2011-06-27 01:41 AM

Values of 'item' nodes in sidebar/content trees have no properties
 
(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 [I]name[/I] 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[/CODE]

RESULT: 'cobj'{ }


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]

[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[/CODE]

RobTrew 2011-06-27 02:39 AM

In fact (I had forgotten) it gets worse - even the tree nodes of group dividers lack identifiable properties ...

In other words, you can't identify at all which grouping divider the user has selected ...

(the following yields neither name nor any other identifiable handle for a selected grouping heading)

[CODE]tell application "OmniFocus"
tell content of front window to return properties of first selected tree where class of its value is item
end tell[/CODE]

(an understandable organisational [I]decalage[/I] - the grouping dividers were introduced after the applescript library had been written - but perhaps room now for a quick conversation over coffee between holders of different skill-sets or engineering roles ? ;-)

[COLOR="White"]--[/COLOR]


All times are GMT -8. The time now is 03:14 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.