The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Values of 'item' nodes in sidebar/content trees have no properties Thread Tools Search this Thread Display Modes
(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 ...)

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
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:
-- 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..
 
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
(an understandable organisational decalage - 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 ? ;-)

--

Last edited by RobTrew; 2011-06-27 at 02:50 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Better outlines than 003, better trees than OG5 ... RobTrew OmniOutliner 3 for Mac 2 2012-07-07 12:26 AM
Object properties based on key-values? josh OmniGraffle General 0 2010-04-08 06:02 AM
Lines with bezier nodes? aangel OmniGraffle General 1 2009-01-03 01:33 PM
Sidebar or content selected? Bug in Applescript support? davidamis OmniFocus Extras 0 2008-05-29 09:29 AM
Trouble with scripts that require selected trees of content akelley OmniFocus Extras 7 2007-12-13 02:40 AM


All times are GMT -8. The time now is 01:28 PM.


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