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 > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Expand a little, collapse a little ... Thread Tools Search this Thread Display Modes
The sample scripts on the OmniOutliner Extras page include:
  • Collapse to Level of Selected Item,
  • and Collapse to Level X
These are fine, but my flow of thought is sometimes disrupted unnecessarily by having to select a target item, or (particularly for expanding) calculate and specify a target level.

It is easier for me to simply:
  • Expand a little,
  • Collapse a little.
(perhaps repeating one of these simple gestures to fine-tune).

This is the pair of scripts which I use:

Expand one level more:
Code:
property plstLevel : {}

AdjustExpansion(1)
set plstLevel to {}

on AdjustExpansion(lngDelta)
	tell application id "com.omnigroup.OmniOutlinerPro3"
		if (count of documents) < 1 then return
		set oDoc to front document
		set lngNewMax to (my DeepestLevel(oDoc, true)) + lngDelta
		tell oDoc
			set expanded of (rows where level ≤ lngNewMax) to true
			set expanded of (rows where level > lngNewMax) to false
		end tell
	end tell
end AdjustExpansion

on DeepestLevel(oDoc, blnExpandedOnly)
	set lngMax to 0
	using terms from application "OmniOutliner Professional"
		if blnExpandedOnly then
			set plstLevel to level of rows of oDoc where expanded is true
		else
			set plstLevel to level of rows of oDoc
		end if
		repeat with iLevel from 1 to length of plstLevel
			set lngLevel to item iLevel of plstLevel
			if lngLevel > lngMax then set lngMax to lngLevel
		end repeat
	end using terms from
	lngMax as integer
end DeepestLevel
Collapse one level more:
Code:
property plstLevel : {}

AdjustExpansion(-1)
set plstLevel to {}

on AdjustExpansion(lngDelta)
	tell application id "com.omnigroup.OmniOutlinerPro3"
		if (count of documents) < 1 then return
		set oDoc to front document
		set lngNewMax to (my DeepestLevel(oDoc, true)) + lngDelta
		tell oDoc
			set expanded of (rows where level ≤ lngNewMax) to true
			set expanded of (rows where level > lngNewMax) to false
		end tell
	end tell
end AdjustExpansion

on DeepestLevel(oDoc, blnExpandedOnly)
	set lngMax to 0
	using terms from application "OmniOutliner Professional"
		if blnExpandedOnly then
			set plstLevel to level of rows of oDoc where expanded is true
		else
			set plstLevel to level of rows of oDoc
		end if
		repeat with iLevel from 1 to length of plstLevel
			set lngLevel to item iLevel of plstLevel
			if lngLevel > lngMax then set lngMax to lngLevel
		end repeat
	end using terms from
	lngMax as integer
end DeepestLevel

Last edited by RobTrew; 2010-11-04 at 11:50 PM.. Reason: Tidied the code a little
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Expand/Collapse All Joseph OmniGraffle General 2 2012-06-21 04:37 PM
OF 1.2 Expand/Collapse all atreinke OmniFocus for iPad 2 2010-11-13 04:06 AM
Toggling between collapse all and expand all RobTrew OmniFocus Extras 4 2010-06-18 02:53 AM
Collapse or expand one section only? rogbar OmniOutliner 3 for Mac 1 2009-01-28 02:06 PM
Expand/collapse notes? marieboyer OmniFocus 1 for Mac 2 2008-08-09 08:29 AM


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


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