In the scripting dictionary, collections of rows have a .setProperty() function. Could you tell me what type of arguments the functions expects in JavaScript for Automation ?
Context - for example - expanding all outline rows in an outline or set of outline peer rows.
(See, in the Webkit debugger:
Sample code: ( rows.setProperty() arguments apparently not correct here ):
(function () {
'use strict';
var oo = Application("com.omnigroup.OmniOutliner4"),
ds = oo.documents,
d = ds.length ? ds.at(0) : undefined;
if (!d) return;
var rows = d.rows,
// any expanded element in outline ?
blnState = rows.expanded().reduce(function (a, e) {
return a ? a : e;
}, false);
//debugger;
rows.setProperty('expanded', !blnState);
})();
For reference, using the .sdef from AppleScript, we might write (to toggle outline expansion)
property pblnState : false
on run {}
tell application id "com.omnigroup.OmniOutliner4"
set ds to documents
if length of ds > 0 then
set d to item 1 of ds
else
return null
end if
tell d
set refRows to a reference to rows
-- BATCH SET PROPERTY ACROSS REFERENCED COLLECTION OF ROWS
set expanded of refRows to pblnState
set pblnState to not pblnState
return expanded of refRows
end tell
end tell
end run
and in osascript JS (JavaScript for Automation), we can batch get the values of the .expanded() state by writing:
rows.getProperty('expanded')();
// --> [true, true, true, false, false, false, true, false, false]
and set the value of an isolated row by using the single row object row.setProperty()
rows.at(0).setProperty('expanded', !blnState);
The question is the syntax of the method call for a plural rows collection - the equivalent of the AppleScript:
set expanded of refRows to pblnState