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

 
Scripting the expansion of notes Thread Tools Search this Thread Display Modes
Just been asked about detecting and setting the expansion state of notes. The short answer is that nodes in the content panel have a note expanded property.

Code:
tell application id "OFOC"
	tell default document
		tell front document window
			tell content
				set oNode to leaf id "eV0HtQ2RJIi" -- choose some task by id, for example
				
				if not note expanded of oNode then
					set note expanded of oNode to true
				end if
			end tell
		end tell
	end tell
end tell
or, for a broader brush:

Code:
tell application id "OFOC"
	tell default document
		tell front document window
			tell content to set note expanded of leaves to true
		end tell
	end tell
end tell
 
This is great. Was looking for a script that expands/collapses the notes in a tree I selected. Not very familiar with AppleScript so was looking for a way to expand the second example script to first get the state if the note is already expanded and if yes collapse it, if not, expand it so I have one instead of two scripts. So basically one script with which I can toggle between expand and collapse the notes. Is there something along the lines of "get note expanded" so I can get the boolean state of the note expanded? Thanks for any tip.
 
You can use the not operator to flip the current state of the note expanded property of a content panel tree node.

Code:
tell application id "OFOC"
	tell default document
		tell content of front document window
			set lstTaskNode to selected trees where class of value is task or class of value is inbox task
			repeat with oTaskNode in lstTaskNode
				tell oTaskNode to set note expanded to (not note expanded)
			end repeat
		end tell
	end tell
end tell
 
Quote:
Originally Posted by RobTrew View Post
You can use the not operator to flip the current state of the note expanded property of a content panel tree node.
... and you can also apply the change to sub-tasks and their descendants:

Code:
tell application id "OFOC"
	tell default document
		tell content of front document window
			set lstTaskNode to selected trees where class of value is task or class of value is inbox task
			repeat with oTaskNode in lstTaskNode
				tell oTaskNode
					set blnNewState to (not note expanded)
					
					-- toggle the selected node
					set note expanded to blnNewState
					
					-- and reset the notes of all descendant tasks to the same new state
					set note expanded of descendant trees to blnNewState
				end tell
			end repeat
		end tell
	end tell
end tell
 
@hwend

There are also some keyboard shortcuts that might help depending on your workflow:
  • cmd-' (command single inverted comma) : has the effect of toggling notes for the currently selected task
  • alt-cmd-' : toggles all notes
 
Yes – only sub-tree toggling is beyond the immediate reach of the keyboard.

[all notes descending from current selection(s)]
 
one for OmniGroup to add to the spec for OF2...

:-)
 
Quote:
Originally Posted by philrob View Post
one for OmniGroup to add to the spec for OF2...

:-)
That will certainly be good if its new skin is worth breaking existing scripts for ...

The data model seems to be the same, so the new UI would have to have some real advantages (and no intrusive or distracting bling or bloat) for me to really want to rewrite/retrieve some of the bigger scripts that I use every day, particularly for data finding/querying.

We will see ...
 
Than you all for your replies and help. I really appreciate it.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -8. The time now is 09:17 AM.


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