Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Indesgin - collapse treeview

Community Beginner ,
Dec 31, 2019 Dec 31, 2019

Hello everobody,

I have build a Window with a TreeView and 2 radio buttons.

1 radio button to expand all nodes // 1 radio button to collapse all nodes

OnClick on each radio button called a specific recursive function that expand or collapse my tree : 

// Expand all treeview nodes 
function expand_tree(my_treeview){
    my_treeview.expanded = true;
    var branches = my_treeview.items;
    for (var i = 0; i < branches.length; i++) {
        if (branches[i].type == 'node') {
            expand_tree (branches[i]);
        }
    }
}
// Collapse all treeview nodes 
function collapse_tree(my_treeview){
    my_treeview.expanded = false;
    var branches = my_treeview.items;
    for (var i = 0; i < branches.length; i++) {
        if (branches[i].type == 'node') {
            collapse_tree (branches[i]);
        }
    }
}

 

expand_tree function expand all nodes into my tree

But, collapse_tree function seems to do nothing…

I think my_treeview.expanded = false is the problem. 

I test it with my_treeview.collapsed = true but unsuccessfully

Do you have any idea ?

Thank you

TOPICS
Scripting
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 06, 2020 Jan 06, 2020

Up please ^^

Nobody with same problem ? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2020 Jan 07, 2020

Hi,

 

I cannot see any obvious problem, are you able to share your whole project so that we have a place to start from?

 

Regards

 

Malcolm

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 07, 2020 Jan 07, 2020

Hi Malcom,

My "sample" code with problem on collapse Treeview.

Thank you in advance

Stéphane

 

#targetengine 'testengine1'

// DIALOG
// ======
var dialog = new Window('palette','My palett'); 
    dialog.text = "Dialog"; 
    dialog.preferredSize.width = 500; 
    dialog.orientation = "column"; 
    dialog.alignChildren = ["left","top"]; 
    dialog.spacing = 10; 
    dialog.margins = 16; 

// GROUP1
// ======
var group1 = dialog.add("group", undefined, {name: "group1"}); 
    group1.orientation = "row"; 
    group1.alignChildren = ["left","center"]; 
    group1.spacing = 10; 
    group1.margins = 0; 

// TREEVIEW1
// =========
var treeview1 = group1.add("treeview", [0,0,500,200], undefined, {name: "treeview1"}); 

var treeitem1 = treeview1.add("node", "TreeItem"); 
var treeitem2 = treeitem1.add("node", "TreeItem"); 
var treeitem3 = treeitem2.add("item", "TreeItem"); 
var treeitem4 = treeitem2.add("item", "TreeItem"); 
var treeitem5 = treeitem1.add("item", "TreeItem"); 
var treeitem6 = treeview1.add("node", "TreeItem"); 
var treeitem7 = treeitem6.add("item", "TreeItem"); 
var treeitem8 = treeitem6.add("item", "TreeItem"); 
var treeitem9 = treeview1.add("item", "TreeItem"); 
var treeitem10 = treeview1.add("node", "TreeItem"); 
var treeitem11 = treeitem10.add("item", "TreeItem"); 
var treeitem12 = treeitem10.add("node", "TreeItem"); 
var treeitem13 = treeitem12.add("item", "TreeItem"); 
var treeitem14 = treeitem12.add("node", "TreeItem"); 
var treeitem15 = treeitem14.add("item", "TreeItem"); 
var treeitem16 = treeitem14.add("item", "TreeItem"); 
var treeitem17 = treeitem10.add("item", "TreeItem"); 

// FOOTER_GROUP
// ============
var footer_group = dialog.add("group", undefined, {name: "footer_group"}); 
    footer_group.preferredSize.width = 500; 
    footer_group.orientation = "row"; 
    footer_group.alignChildren = ["right","center"]; 
    footer_group.spacing = 10; 
    footer_group.margins = 0; 

// RB_GROUP
// ========
var RB_group = footer_group.add("group", undefined, {name: "RB_group"}); 
    RB_group.preferredSize.width = 400; 
    RB_group.orientation = "row"; 
    RB_group.alignChildren = ["left","center"]; 
    RB_group.spacing = 10; 
    RB_group.margins = 0; 

var RB_expand = RB_group.add("radiobutton", undefined, undefined, {name: "RB_expand"}); 
    RB_expand.text = "Expand"; 

var RB_collapse = RB_group.add("radiobutton", undefined, undefined, {name: "RB_collapse"}); 
    RB_collapse.text = "Collapse"; 
    RB_collapse.value = true;

    RB_expand.onClick = function (){ expand_tree(treeview1); }
    RB_collapse.onClick = function (){ collapse_tree(treeview1); }

// FOOTER_GROUP
// ============
var button1 = footer_group.add("button", undefined, undefined, {name: "close"}); 
    button1.text = "Close"; 
    button1.justify = "right"; 
    button1.onClick = function(){ dialog.close(); }

dialog.show();


// Expand all treeview nodes 
function expand_tree(my_treeview){
    my_treeview.expanded = true;
    var branches = my_treeview.items;
    for (var i = 0; i < branches.length; i++) {
        if (branches[i].type == 'node') {
            expand_tree (branches[i]);
        }
    }
}
// Collapse all treeview nodes 
function collapse_tree(my_treeview){
    my_treeview.expanded = false;
    var branches = my_treeview.items;
    for (var i = 0; i < branches.length; i++) {
        if (branches[i].type == 'node') {
            collapse_tree (branches[i]);
        }
    }
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 07, 2020 Jan 07, 2020

Small precision : 

I test it on Indesign CC 2019 on Mac OSX 10.13.14

With Extented Toolkit CC 4.0.0.1

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2020 Jan 07, 2020

I ran a quick test on my older InDesign (CS4!), and both expanding and collapsing worked there as well...

The only problem I saw was that sometimes redrawing went out of whack. Running the collapse_tree loop in reverse fixed that:

 

// Collapse all treeview nodes 
function collapse_tree(my_treeview){
    my_treeview.expanded = false;
    var branches = my_treeview.items;
    for (var i = branches.length-1; i>=0; i--) {
        if (branches[i].type == 'node') {
            collapse_tree (branches[i]);
        }
    }
}

 

But this is on my Windows machine; you might very well have a Mac-only bug. It would not be the only one ...

ScriptUI needs love, badly!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 07, 2020 Jan 07, 2020

I just tested on CC 2019 on Windows and I have same problem...

Expand is OK, Collapse no.

Test with initial collapse_tree function and your collapse_tree function.

So it's not a Mac-only bug. But a CC (2019?) bug?

If that's case, is there a solution ?Any hope to get a patch?

Anyway, thank you for testing

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2020 Jan 07, 2020

Hi Stéphane,

it's likely a bug that sneeked in with the change from InDesign CS6 version 8 to InDesign CC version 9.

As many bugs did that are with ScriptUI after changing InDesign from 32-bit to 64-bit code.

 

From InDesign CC version 9.3.0 on Windows:

 

Initial state after executing your code:

 

TreeView-1-CC.PNGexpand image

 

Clicked "Expand". Note the scroll bar is at the expected position showing the top items:

 

TreeView-2-Expand-CC.PNGexpand image

 

Then back to "Collapse". Obviously that is not working:

 

TreeView-3-Collapse-CC.PNGexpand image

 

However I could collapse the items one by one "manually" in the item list using a click with my mouse:

 

TreeView-4-Collapse-Manually-NodeByNode-CC.PNGexpand image

 

 

Just testing the same with InDesign CS6 version 8.1.0 on the same system.

 

Initial state of window after executing your code:

( Note the difference in used icons for the nodes. )

 

TreeView-1-CS6.PNGexpand image

 

Clicking on "Expand". The scroll bar is not showing the first items in the list. Maybe a bug with CS6?

At least a different behavior compared to InDesign CC.

 

TreeView-2-Expand-CS6.PNGexpand image

 

Clicking "Collapse" again.

Note the difference to the initial screenshot with CS6. Another bug with CS6 maybe?

The connector between node 2 and 3 is indented too much.

TreeView-3-Collapse-CS6.PNGexpand image

 

I see no immediate solution to your problem.

Best report the issue at:

https://indesign.uservoice.com/

 

When done, please come back and post the link to your report so that we can vote for fixing the issue.

 

Thanks,
Uwe Laubender

( ACP )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 07, 2020 Jan 07, 2020

Hi Uwe,
Thank you for feedback and detailed answer.
I posted the bug to the following address:

https://indesign.uservoice.com/forums/913162-adobe-indesign-sdk-scripting-bugs-and-features/suggesti...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2020 Jan 07, 2020

Voted.

 

Regards,
Uwe Laubender

( ACP )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2020 Jan 07, 2020

Hi Stéphane,

think, we are still lucky with tree view and InDesign.

With PhotoShop it's not available anymore since Flash was removed:

 

February 15, 2017

Photoshop UI toolkit for plug-ins and scripts

Known issues

 

The Flash Player widget is no longer supported. It is not possible to play SWF/Flash/Flex files through the script UI any longer.
Treeview widget is not supported.
Graphics drawing is not supported on Checkbox and Radiobutton widgets.
Button background color cannot be changed.
Font styles on text are not supported

 

https://helpx.adobe.com/photoshop/using/ScriptUI.html#Knownissues

 

Regards,
Uwe Laubender

( ACP )

 

// EDITED: ADDED DETAILS

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 07, 2020 Jan 07, 2020
LATEST

Doesn't smell right for a fix…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines