Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


listitem.checked on indesign 15.0 (2020)

Community Beginner ,
Nov 12, 2019 Nov 12, 2019

Copy link to clipboard

Copied

Hi... today i have update indesign with 2020 version, but i have find a litle problem for my older script:

with the new version all form create by script cant show checkmark at left of listitem when the property "listitem.checked" its "true"...

 

any suggestion for solving?

TOPICS
Bug, Scripting, SDK

Views

933

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 12, 2019 Nov 12, 2019

Copy link to clipboard

Copied

More details plz.

Likes

Translate

Translate

Report

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 ,
Nov 12, 2019 Nov 12, 2019

Copy link to clipboard

Copied

for example you can try with this simple script:

 

#target indesign

var x = new Window ("dialog","test win", [0,0,150,150])
var y = x.add("listbox",[10,10,140,116])
for (var i=0;i<5;i++) {
y.add("item", "test " + i)

 

// this is the problem... on object model i can find this property but checkmark are not show...
y.items[i].checked = true


}

x.center()
x.show()

 

...

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 12, 2019 Nov 12, 2019

Copy link to clipboard

Copied

Yup, looks like a bug. I'll report it on the prerelease...

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 12, 2019 Nov 12, 2019

Copy link to clipboard

Copied

Hi Mirco,

I can confirm the bug.

Tested with InDesign CC 2019: All items are checked visibly:

 

Checked-Property-WORKING-InDesign2019.PNG

 

Tested with InDesign 2020 version 15.0.0.155: Not working. Means, the checkboxes are missing visibility. Only their indention is visible, the white space after the check box. See far below for more details on this.

 

Checked-Property-NOT-WORKING-InDesign2020.PNG

 

Here a test where I set the value for checked on the first item only to true ( note the little indention here )

 

Checked-Property-FIRST-ITEM-ONLY-NOT-WORKING-InDesign2020.PNG

 

All other items return value undefined with property checked. Property checked can have 3 states:

undefined, true or false. If not declared the value is undefined and no checkbox is drawn.

 

Below the same code executed with InDesign CC 2019:

Checked-True-for-FIRST-ITEM-ONLY-InDesign-CC2019.PNG

 

Now you can see ( or perhaps guess ) that with InDesign 2020 "only" the checkbox is missing, checked or not. The white space after the invisible checkbox is always showing up.

 

Regards,
Uwe Laubender

( ACP )

 

EDITED: Still not fixed with version 15.0.1.209

Likes

Translate

Translate

Report

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 ,
Nov 12, 2019 Nov 12, 2019

Copy link to clipboard

Copied

unfortunately this confirms that there is currently something I can do at the code level to solve this bug ... I will have to modify my previous scripts to remedy this problem unfortunately ...
thank you all for the answers! I hope a fix is coming soon ...

Likes

Translate

Translate

Report

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 ,
Nov 26, 2019 Nov 26, 2019

Copy link to clipboard

Copied

I just added the listitem.image to my script giving a green box for checked and a blank box for unchecked.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 30, 2019 Nov 30, 2019

Copy link to clipboard

Copied

I put a text-based rendition: "[+]" into the first column.

Likes

Translate

Translate

Report

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 ,
Dec 01, 2019 Dec 01, 2019

Copy link to clipboard

Copied

me too for first time... but use listitem.image is a solution that I prefer...

Likes

Translate

Translate

Report

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
Explorer ,
Feb 26, 2020 Feb 26, 2020

Copy link to clipboard

Copied

Would anyone be willing to help me with a re-write?  This issue seems to have broken a script that I have been using and the original author seems to have gone off the radar... unfortunately I am not well versed in JSX enough to figure this out on my own.. 

 

https://community.adobe.com/t5/indesign/layer-visibility-overrides-for-all-instances-of-a-linked-fil...

 

Original Script that worked with 2019:

#targetengine batchLayerVisibility  
  
main();  
  
function main() {  
    proceed = false;  
     
    if (app.selection.length == 0) {  
        alert("Nothing selected.");  
        exit();  
    }  
  
    var sel = app.selection[0];  
     
    try {  
        var test = sel.graphicLayerOptions.graphicLayers;  
        if (test.length == 0) {  
            alert("Selected object not supported.");  
            exit();  
        }  
        } catch (err) {  
            alert("Please select an .AI image with the white selection tool or click in the links panel on the graphic.");  
            exit();  
        }  
     
    var graphicFile = sel.itemLink.filePath;  
    instances = new Array();  
    var allGraphics= app.activeDocument.allGraphics;  
     
    // collect instances  
    for (var i = 0; i < allGraphics.length; i++) {  
        if (allGraphics[i].itemLink == null) {continue;}  
        if (allGraphics[i].itemLink.filePath == graphicFile) {  
            instances.push(allGraphics[i]);  
        }  
    }  
  
    instancesCount = instances.length;  
     
    makeWindow();  
}  
  
function makeWindow() {  
    var w = new Window("dialog", "Batch Layer Visibility 1.2");  
    w.alignChildren = ["fill", "fill"];  
    checkboxes = new Array();  
     
    var panel = w.add("panel", undefined, "Layer Visibility");  
    panel.alignChildren = ["fill", "fill"];  
     
    layerList = panel.add("listbox", [0, 0, 400, 500], undefined, {multiselect: false, scrolling: true});  
     
    for (var i = 0; i < instances[0].graphicLayerOptions.graphicLayers.length; i++) {  
        var tempItem = layerList.add("item", instances[0].graphicLayerOptions.graphicLayers[i].name);  
        tempItem.checked = instances[0].graphicLayerOptions.graphicLayers[i].currentVisibility;  
        //tempItem.onClick = function () {alert();}  
    }  
  
    layerList.onChange =setCheckboxStatus; // call function setCheckboxStatus  
     
    checkboxes = layerList.items;  
     
    update_options = new Array();  
     
    updateOptionsPanel = w.add("panel", undefined, "Link Update Options");  
    updateOptionsPanel.alignChildren = ["fill", "fill"];  
    update_options[0] = updateOptionsPanel.add("radiobutton", undefined, "PDF Visibility");  
    update_options[1] = updateOptionsPanel.add("radiobutton", undefined, "Custom Visibility");  
     
    if (app.selection[0].graphicLayerOptions.updateLinkOption.toString() == "APPLICATION_SETTINGS") {  
        update_options[0].value = true;  
    } else {update_options[1].value = true;}  
     
    var btnGrp = w.add("group");  
    btnGrp.orientation = "row";  
     
    var closeBtn = btnGrp.add("button", undefined, "Exit");  
    closeBtn.onClick = function () {  
        proceed = false;  
        w.close();  
        exit();  
    }  
     
    var exeBtn = btnGrp.add("button", undefined, "OK", {name: "ok"});  
    exeBtn.onClick = function() {  
        proceed = true;  
        w.close();  
    }  
     
    w.show();  
}  
  
if (proceed == true) {  
    app.doScript(setVisibility, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.entireScript, "Batch Layer Visibility");  
}  
  
function setVisibility() {  
    pbar();  
     
    var graphicFile = app.selection[0].itemLink.filePath;  
     
    for (var c = 0; c < checkboxes.length; c++) {  
         
        var allGraphics= app.activeDocument.allGraphics;  
         
        // seek instances and change visibility  
        for (var i = 0; i < allGraphics.length; i++) {  
            if (allGraphics[i].itemLink == null) {continue;}  
            if (allGraphics[i].itemLink.filePath == graphicFile) {  
                 
                //pbar_instance.value++;  
                 
                allGraphics[i].graphicLayerOptions.graphicLayers[c].currentVisibility = checkboxes[c].checked;  
                 
                pbar_layer.value++;  
            }  
        }  
    }  
  
    allGraphics = app.activeDocument.allGraphics;  
     
    // set link update option  
    for (var i = 0; i < allGraphics.length; i++) {  
        if (allGraphics[i].itemLink == null) {continue;}  
        if (allGraphics[i].itemLink.filePath ==graphicFile) {  
            if (updateOptionSel = updateOptionsPanel.children[0].value == true) {  
                allGraphics[i].graphicLayerOptions.updateLinkOption = UpdateLinkOptions.APPLICATION_SETTINGS;  
            } else {  
                allGraphics[i].graphicLayerOptions.updateLinkOption = UpdateLinkOptions.KEEP_OVERRIDES;  
            }  
            pbar_layer.value++;  
        }  
    }  
     
    pbarWindow.close();  
     
}  
  
function setCheckboxStatus() {  
     
    if (layerList.selection.checked == true) {  
        layerList.selection.checked = false;  
    } else {layerList.selection.checked = true;}  
    var tempSel = layerList.selection;  
    layerList.selection = null;  
  
}  
  
function pbar () {  
    pbarWindow = new Window ("palette", "Processing ...", undefined);  
    pbarPanel = pbarWindow.add("panel");  
     
    //pbarPanel.add("statictext", undefined, "Instances");  
    //pbar_instance = pbarPanel.add("progressbar", undefined, 0, instancesCount);  
     
    pbarPanel.add("statictext", undefined, "Progress:");  
    pbar_layer = pbarPanel.add("progressbar", undefined, 0, (instancesCount * checkboxes.length) + instancesCount);  
    pbar_layer.preferredSize.width = 200;  
     
    pbarWindow.show();  
     
}  

 

Likes

Translate

Translate

Report

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 ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

Under the creation of the list item you need to add the images. Since the items can start as checked, you have to allow for both checked and unchecked.

 

 for (var i = 0; i < instances[0].graphicLayerOptions.graphicLayers.length; i++) {  
        var tempItem = layerList.add("item", instances[0].graphicLayerOptions.graphicLayers[i].name);  
        tempItem.checked = instances[0].graphicLayerOptions.graphicLayers[i].currentVisibility;  
        if(tempItem.checked){
            tempItem.image = ScriptUI.newImage(/*full file name and path for checked image*/);
        }else{
           tempItem.image = ScriptUI.newImage(**full file name and path for unchecked image**);
        }
        //tempItem.onClick = function () {alert();}  
    }  

 

I keep the images in the same folder as the script so my path is (new File($.fileName)).parent + '/checkedItemF.png'.

You also need to add the non checked and checked images to the setCheckboxStatus() function.

 

function setCheckboxStatus() {  
     
    if (layerList.selection.checked == true) {  
        layerList.selection.checked = false;
        layerList.selection.image = ScriptUI.newImage(/*full file name and path for unchecked image*/);
    } else {
        layerList.selection.checked = true;
        layerList.selection.image = ScriptUI.newImage(/*full file name and path for checked image*/);
    }  
    var tempSel = layerList.selection;  
    layerList.selection = null;  
  
}  

 

I think I caught all of the instances where it is affected.

Likes

Translate

Translate

Report

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
Explorer ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

Thank you so much!! 

Ok so let me see if I understand this correctly... so I would need to create checked and unchecked PNG images and place them in the same folder as the script?  If so, what size would these need to be? 

 

and if that is correct... I would change the line to:

layerList.selection.image = ScriptUI.newImage(new File($.fileName)).parent + '/checkedItemF.png');

 

What I am not seeing is where it would call the unchecked png.. and what that file name would need to be?  

Likes

Translate

Translate

Report

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 ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

Yes, for consistency sake. You could possibly just use a checked image, but that hurts my need for symmetry.

Personally I used the wingdings box at a similar font size of my text as my starting shape.

The 'checkedItemF.png' is the name I used for my unchecked box. My checked box is actually 'checkedItemT.png'.

I was just trying to give you a reference for how to call a file from the same parent folder. It just needs to be the name that you use for your images either the checked or unchecked.

Don't forget the initial '/'.

Really what you use for the images is up to you and your aesthetics. Wingdings are an easy starting point though.

Likes

Translate

Translate

Report

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
Explorer ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

Ok, so I placed png files named uncheckedItemF.png & checkedItemF.png in the same folder as the script.

 

I am getting this error:

error at line 57error at line 57

 

 

My code has been edited to this: 

#targetengine batchLayerVisibility  
  
main();  
  
function main() {  
    proceed = false;  
     
    if (app.selection.length == 0) {  
        alert("Nothing selected.");  
        exit();  
    }  
  
    var sel = app.selection[0];  
     
    try {  
        var test = sel.graphicLayerOptions.graphicLayers;  
        if (test.length == 0) {  
            alert("Selected object not supported.");  
            exit();  
        }  
        } catch (err) {  
            alert("Please select an .AI image with the white selection tool or click in the links panel on the graphic.");  
            exit();  
        }  
     
    var graphicFile = sel.itemLink.filePath;  
    instances = new Array();  
    var allGraphics= app.activeDocument.allGraphics;  
     
    // collect instances  
    for (var i = 0; i < allGraphics.length; i++) {  
        if (allGraphics[i].itemLink == null) {continue;}  
        if (allGraphics[i].itemLink.filePath == graphicFile) {  
            instances.push(allGraphics[i]);  
        }  
    }  
  
    instancesCount = instances.length;  
     
    makeWindow();  
}  
  
function makeWindow() {  
    var w = new Window("dialog", "Batch Layer Visibility 1.2");  
    w.alignChildren = ["fill", "fill"];  
    checkboxes = new Array();  
     
    var panel = w.add("panel", undefined, "Layer Visibility");  
    panel.alignChildren = ["fill", "fill"];  
     
    layerList = panel.add("listbox", [0, 0, 400, 500], undefined, {multiselect: false, scrolling: true});  
     
     for (var i = 0; i < instances[0].graphicLayerOptions.graphicLayers.length; i++) {  
        var tempItem = layerList.add("item", instances[0].graphicLayerOptions.graphicLayers[i].name);  
        tempItem.checked = instances[0].graphicLayerOptions.graphicLayers[i].currentVisibility;  
        if(tempItem.checked){
            tempItem.image = ScriptUI.newImage(new File($.fileName)).parent + '/checkedItemF.png');
        }else{
           tempItem.image = ScriptUI.newImage(new File($.fileName)).parent + '/uncheckedItemF.png');
        }
        //tempItem.onClick = function () {alert();}  
    } 
  
    layerList.onChange =setCheckboxStatus; // call function setCheckboxStatus  
     
    checkboxes = layerList.items;  
     
    update_options = new Array();  
     
    updateOptionsPanel = w.add("panel", undefined, "Link Update Options");  
    updateOptionsPanel.alignChildren = ["fill", "fill"];  
    update_options[0] = updateOptionsPanel.add("radiobutton", undefined, "PDF Visibility");  
    update_options[1] = updateOptionsPanel.add("radiobutton", undefined, "Custom Visibility");  
     
    if (app.selection[0].graphicLayerOptions.updateLinkOption.toString() == "APPLICATION_SETTINGS") {  
        update_options[0].value = true;  
    } else {update_options[1].value = true;}  
     
    var btnGrp = w.add("group");  
    btnGrp.orientation = "row";  
     
    var closeBtn = btnGrp.add("button", undefined, "Exit");  
    closeBtn.onClick = function () {  
        proceed = false;  
        w.close();  
        exit();  
    }  
     
    var exeBtn = btnGrp.add("button", undefined, "OK", {name: "ok"});  
    exeBtn.onClick = function() {  
        proceed = true;  
        w.close();  
    }  
     
    w.show();  
}  
  
if (proceed == true) {  
    app.doScript(setVisibility, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.entireScript, "Batch Layer Visibility");  
}  
  
function setVisibility() {  
    pbar();  
     
    var graphicFile = app.selection[0].itemLink.filePath;  
     
    for (var c = 0; c < checkboxes.length; c++) {  
         
        var allGraphics= app.activeDocument.allGraphics;  
         
        // seek instances and change visibility  
        for (var i = 0; i < allGraphics.length; i++) {  
            if (allGraphics[i].itemLink == null) {continue;}  
            if (allGraphics[i].itemLink.filePath == graphicFile) {  
                 
                //pbar_instance.value++;  
                 
                allGraphics[i].graphicLayerOptions.graphicLayers[c].currentVisibility = checkboxes[c].checked;  
                 
                pbar_layer.value++;  
            }  
        }  
    }  
  
    allGraphics = app.activeDocument.allGraphics;  
     
    // set link update option  
    for (var i = 0; i < allGraphics.length; i++) {  
        if (allGraphics[i].itemLink == null) {continue;}  
        if (allGraphics[i].itemLink.filePath ==graphicFile) {  
            if (updateOptionSel = updateOptionsPanel.children[0].value == true) {  
                allGraphics[i].graphicLayerOptions.updateLinkOption = UpdateLinkOptions.APPLICATION_SETTINGS;  
            } else {  
                allGraphics[i].graphicLayerOptions.updateLinkOption = UpdateLinkOptions.KEEP_OVERRIDES;  
            }  
            pbar_layer.value++;  
        }  
    }  
     
    pbarWindow.close();  
     
}  
  
function setCheckboxStatus() {  
     
if (layerList.selection.checked == true) {  
        layerList.selection.checked = false;
        layerList.selection.image = ScriptUI.newImage(new File($.fileName)).parent + '/uncheckedItemF.png');
    } else {
        layerList.selection.checked = true;
        layerList.selection.image = ScriptUI.newImage(new File($.fileName)).parent + '/checkedItemF.png');
    }  
    var tempSel = layerList.selection;  
    layerList.selection = null;    
  
}  
  
function pbar () {  
    pbarWindow = new Window ("palette", "Processing ...", undefined);  
    pbarPanel = pbarWindow.add("panel");  
     
    //pbarPanel.add("statictext", undefined, "Instances");  
    //pbar_instance = pbarPanel.add("progressbar", undefined, 0, instancesCount);  
     
    pbarPanel.add("statictext", undefined, "Progress:");  
    pbar_layer = pbarPanel.add("progressbar", undefined, 0, (instancesCount * checkboxes.length) + instancesCount);  
    pbar_layer.preferredSize.width = 200;  
     
    pbarWindow.show();  
     
}  

 

Likes

Translate

Translate

Report

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 ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

It is a mismatch of (s and )s. You need another ( before new File.

 

tempItem.image = ScriptUI.newImage((new File($.fileName)).parent + '/checkedItemF.png');

 

Likes

Translate

Translate

Report

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
Explorer ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

Bingo, good eye!! Thanks John!!!! 

 

It almost works perfect... Not a deal breaker but bugs the perfectionist in me. 

 

Initially it loads with no boxes... 

on loadon load

 

Then after I click on one, the boxes appear. 

On ClickOn Click

Likes

Translate

Translate

Report

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 ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

LATEST

Yep. That is ScriptUI wonkiness. You will also notice them falling off the top and bottom if it is a scrollable list. I have not seen a way around it.

It might be a refresh issue.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

This also began as a problem in Illustrator 2020.

 

Just as an interesting factoid, ScriptUI.newImage is actually not necessary, just the File(..image path) object will do.

Likes

Translate

Translate

Report

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