Copy link to clipboard
Copied
So when creating a dialogue using app.execDialog(), it is possible to have a hierarchical box list with the element type "hier_box_list".
It is then possible to get a return of the child node that is selected. However, I haven't find a way to get anything returned if I have a parent node selected.
I used the example 4 from the JavaScript API, page 84-87, to create the code below. Unfortunately this just returns a "undefined" when a parent node (like "Chapter 1", "Section 1", or "Section 2") is selected.
var dialog4 = {
selection : {
"Chapter 1" : {
"Section 1" : {
"SubSection 1" : -1,
"SubSection 2" : -2,
},
"Section 2" : {
"SubSection 1" : -3,
"SubSection 2" : -4,
}
},
"Chapter 3" : -5,
"Chapter 4" : -6,
},
Return : "",
initialize : function (dialog) {
dialog.load({
subl : this.selection
})
},
subl : function (dialog) {
var element = dialog.store()["subl"];
this.Return = this.getHierChoice(element);
console.println("\nSelection Box Hit: " + this.Return);
},
getHierChoice : function (e) {
if (typeof e == "object") {
for (var i in e) {
if (typeof e == "object") {
var retn = this.getHierChoice(e);
if (retn) {
retn = i + ", " + retn;
return retn;
}
// if e > 0, we’ve found the selected item
} else if (e > 0)
return i;
}
} else {
if (e > 0)
return e;
}
},
commit : function (dialog) {
this.selection = dialog.store()["subl"];
},
cncl : function (dialog) {
dialog.end("cancel")
},
// Dialog box description
description : {
name : "My Novel",
elements :
[{
type : "view",
align_children : "align_left",
elements :
[{
type : "cluster",
name : "Book Headings",
elements :
[{
type : "static_text",
name : "Make a selection",
}, {
type : "hier_list_box",
item_id : "subl",
char_width : 20,
height : 200
}
]
}, {
type : "ok_cancel",
}
]
}
]
}
};
function dotheDialog(dialog, doc) {
dialog.doc = doc;
var retn = app.execDialog(dialog)
};
dotheDialog(dialog4, this);
Does anybody know how I could have this return something if the user selects a parent node?
Copy link to clipboard
Copied
It doesn't seem like it's possible. You can only return the lowest-level nodes of the hierarchy. A workaround could be to use something like this (see what I did with "Chapter 1":
selection : {
"Chapter 1" : -1,
"-" : {
"Section 1" : {
"SubSection 1" : -2,
"SubSection 2" : -3,
},
"Section 2" : {
"SubSection 1" : -4,
"SubSection 2" : -5,
}
},
"Chapter 3" : -6,
"Chapter 4" : -7,
},
Copy link to clipboard
Copied
This doesn't really work, because the "-" will always appear as the first entry, because entries are ordered alphabetically. It might work by using the undocumented dialog.insertEntryInList() function and adding all the elements one at a time.
However, this isn't very self-explanatory for users. I am thinking about going an alternative route where the user gets a (second) pop-up to select the node, if the code doesn't detect any positive values.
Copy link to clipboard
Copied
Then use "Chapter 1 Options", and it will appear directly after it.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now