Copy link to clipboard
Copied
Hi,
I'm trying to set the geometricBounds of a PageItem and that works fine until I do it within a button click handler, then nothing happens.
Code:
function createDialog(header, message, pageItem) {
var dialog = new Window("dialog", header),
textArea = dialog.add("statictext {preferredSize: [200, 100], properties: {multiline: true}}"),
correctButton = dialog.add("button", undefined, "Correct");
textArea.text = message;
correctButton.onClick = function() {
alert('Before');
pageItem.geometricBounds = [1, 1, 8, 8];
alert('After');
}
dialog.show()
}Also, only the first alert pops up. 'After' is never shown.
Any ideas?
A dialog is a modal window. While it is active the script cannot "write" to indesign (it can read values from various objects, like those geometric bounds) but it cannot change them.
Solutions:
a) use a palette.
b) in the "onClick" handler record the geometric bounds, but only apply them once the dialog is closed:
if (dialog.show()==1){pageItem.geometricBounds=myRecordedBounds;}
Copy link to clipboard
Copied
A dialog is a modal window. While it is active the script cannot "write" to indesign (it can read values from various objects, like those geometric bounds) but it cannot change them.
Solutions:
a) use a palette.
b) in the "onClick" handler record the geometric bounds, but only apply them once the dialog is closed:
if (dialog.show()==1){pageItem.geometricBounds=myRecordedBounds;}
Copy link to clipboard
Copied
That makes sense.
Thanks so much for all the help
!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more