The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Scripting the expansion of notes (http://forums.omnigroup.com/showthread.php?t=30312)

RobTrew 2013-07-11 11:34 PM

Scripting the expansion of notes
 
Just been asked about detecting and setting the expansion state of notes. The short answer is that nodes in the content panel have a [I]note expanded[/I] 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[/CODE]

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

hwend 2013-10-13 07:49 PM

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.

RobTrew 2013-10-13 11:12 PM

You can use the [I]not[/I] operator to flip the current state of the [I]note expanded[/I] 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[/CODE]

RobTrew 2013-10-13 11:25 PM

[QUOTE=RobTrew;127926]You can use the [I]not[/I] operator to flip the current state of the [I]note expanded[/I] property of a content panel tree node.[/QUOTE]

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

philrob 2013-10-13 11:27 PM

@hwend

There are also some keyboard shortcuts that might help depending on your workflow:
[LIST][*]cmd-' (command single inverted comma) : has the effect of toggling notes for the currently selected task[*]alt-cmd-' : toggles all notes [/LIST]

RobTrew 2013-10-13 11:32 PM

Yes – only sub-tree toggling is beyond the immediate reach of the keyboard.

[all notes descending from current selection(s)]

philrob 2013-10-13 11:52 PM

one for OmniGroup to add to the spec for OF2...

:-)

RobTrew 2013-10-14 12:13 AM

[QUOTE=philrob;127930]one for OmniGroup to add to the spec for OF2...

:-)[/QUOTE]

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 ...

hwend 2013-10-14 08:06 PM

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


All times are GMT -8. The time now is 02:24 PM.

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