I don't understand how the inheritDialog parameter could be passed to app.execDialog() except as a call from one of the dialog box handlers (?) I've tried putting app.execDialog() before dialog.end(), or after dialog.end() and passing the dialog object; in both cases it generates a new dialog, just the same as if I'd not included the parameter. It also builds up the stack because the previous dialog is still there.
I've also tried passing the dialog variable to a global variable, and running app.execDialog(monitor, passedDialog) but that obviously doesn't work because the dialog has already been destroyed by the time it gets there, and it does exactly the same as without the second parameter (destroys the first dialog, then shows the second call).
If anyone has used it, or knows how, please: I'd like to know.
Thanks.
FWIW this is my test script:
Code: Select all
// test of changing dialog with call from within the handler
function randDia(newSnips,insideHandler=true) {
let lastDia;
const dia = {
toLoad: {}, // scripts to load
initialize(dialog) {
const stack = new Error("message").stack;
console.println(stack);
this.toLoad.info = "Select 'random' to redraw - stack length: " + stack.split('\n').length;
dialog.load(this.toLoad);
},
other(dialog) {
if (insideHandler) {
dia.description = addRows(parseInt(Math.random()*9+1));
dialog.end(app.execDialog(dia, dialog));
} else {
lastDia = dialog;
dialog.end('other');
}
},
commit(dialog) {
const dVals = dialog.store();
this.toLoad = dVals;
},
};
function addRows(numRows) {
const description = { name: "Add rows", elements: [
{ type: 'static_text', item_id: 'info', width: 300, bold: true},
{ type: 'ok_cancel_other', other_name: 'random'},
]};
// add rows of checkboxes
newSnips.forEach ((s,i) => {
if (i<numRows) {
description.elements.splice(i+1, 0, {type: 'view', align_children: 'align_row', elements:[
{type: 'check_box', item_id: 'scr'+i.toString(36)},
{type: 'static_text', name: s.labl || 'script ' + (i+1), width: 280, alignment: 'align_fill'}
]});
dia.toLoad['scr'+i.toString(36)] = true;
}
});
return description;
}
let res = 'other';
if (insideHandler) {
dia.description = addRows(parseInt(Math.random()*9+1));
res = app.execDialog(dia);
} else {
while ('other' === res) {
dia.description = addRows(parseInt(Math.random()*9+1));
res = app.execDialog(dia, lastDia);
}
}
if ('ok' !== res) return; // cancelled
// something else
}
// run it inside the dialog
randDia([{labl:"inside 1"}, {labl:"inside 2"}, {labl:"inside 3"}, {labl:"inside 4"}, {labl:"inside 5"}, {labl:"inside 6"}, {labl:"inside 7"}, {labl:"inside 8"}, {labl:"inside 9"}]);
// outside the dialog
randDia([{labl:"outside 1"}, {labl:"outside 2"}, {labl:"outside 3"}, {labl:"outside 4"}, {labl:"outside 5"}, {labl:"outside 6"}, {labl:"outside 7"}, {labl:"outside 8"}, {labl:"outside 9"}], false);