Copy link to clipboard
Copied
Dear friends,
My script finally shall create a tree view displaying the heading-structure of a document.
One detail is that window and tree should be resizeable.
It's easy to resize the window, but for the tree to adapt to the new space I have no success.
It's also a question to me, why the OnResiz is triggered before I touch the created window.
Do You have any ideas where I need to change?
Klaus
/* TreeViewResize.jsx ====== UTF-8 =========================================
Create a tree contents and experiment with resizing
Refrence C:\Program Files (x86)\Adobe\Adobe Utilities - CS6\ExtendScript Toolkit CS6\SDK\Samples\javascript\SnpCreateTreeView.jsx
Rick Quatro's DocNav.jsx
*/
main ();
function main () {
var j, k, oTree, wViewTree;
wViewTree = new Window("palette", "Static (generated) tree", undefined, {resizeable: true});
oTree = wViewTree.add("treeview");
// oTree.preferredSize = [300, 200];
for(var j = 0;j < 10;j++) { // Add static items to the list, in a hierarchical structure.
oTree.add("node", "Item " + j);
for(k = 0; k < 4; k++) {
oTree.items[j].add("item", "Sub Item " + k);
}
}
// --- behaviour of the window -------------------
wViewTree.onResize = Resize (wViewTree, oTree);
// --- final actions -----------------------------
ExpandNode(oTree);
wViewTree.show();
} // end of main
function Resize (wViewTree, oTree) { // Resize window and tree =============
var wSize;
wViewTree.layout.resize ();
alert ("Why is this entered before I do a resize?");
/* --- this poart does not work at all
wSize = wViewTree.preferredSize;
$.bp(true);
//oTree.minimumSize = [wSize[0]-30, wSize[1]-30];
wViewTree.show();
*/
} // end of Resize
function ExpandNode (tree){ // Expand all nodes to see the tree ============
tree.expanded = true;
var branches = tree.items;
for (var i = 0; i < branches.length; i++) {
if (branches[i].type == 'node') {
ExpandNode (branches[i]);
}
}
} // end of ExpandNode
It turns out, that
I got the 'inspiration' from https://stackoverflow.com/questions/46459921/recursively-populate-treeview-from-paths-in-extendscript.
/* TreeViewResize.jsx ====== UTF-8 =========================================
Create a tree contents and experiment with resizing
Refrence …CS6\ExtendScript Toolki
...
Copy link to clipboard
Copied
It turns out, that
I got the 'inspiration' from https://stackoverflow.com/questions/46459921/recursively-populate-treeview-from-paths-in-extendscrip....
/* TreeViewResize.jsx ====== UTF-8 =========================================
Create a tree contents and experiment with resizing
Refrence …CS6\ExtendScript Toolkit CS6\SDK\Samples\javascript\SnpCreateTreeView.jsx
*/
main ();
function main () {
var j, k, oTree, wPalT;
wPalT = new Window("palette", "Static (generated) tree", undefined, {resizeable: true});
wPalT.g1 = wPalT.add("group");
wPalT.g1.alignment = ["fill", "fill"];
oTree = wPalT.g1.add("treeview", undefined);
oTree.preferredSize = [150, 200];
oTree.alignment = ["fill", "fill"];
for(var j = 0;j < 10;j++) {// Add static items to the list
oTree.add("node", "Item " + j);
for(k = 0; k < 4; k++) {
oTree.items[j].add("item", "Sub Item " + k);
}
}
// --- behaviour of the window -------------------
wPalT.onResize = function () {
this.layout.resize();
}
// --- final actions -----------------------------
ExpandNode(oTree);
wPalT.show();
} // end of main
function ExpandNode (tree){ // Expand all nodes to see the tree ============
tree.expanded = true;
var branches = tree.items;
for (var i = 0; i < branches.length; i++) {
if (branches[i].type == 'node') {
ExpandNode (branches[i]);
}
}
} // end of ExpandNode