Copy link to clipboard
Copied
When I enter more than 255 characters in a prompt(), the returning value gets cut off at character 255.
Illustrator 25.4.1
WIN 11 64-bit
I run the script by clicking File > Scripts > Other Script... and then navigating to the script. When prompted I just copy the value initially assigned to the variable, paste and click OK.
Script:
var pastedValues = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
alert(pastedValues + "has a length of " + pastedValues.length);
pastedValues = prompt("Paste values", "");
alert(pastedValues + "has a length of " + pastedValues.length);
Thanks.
Hi @m1cmdrpitch, here is a function I wrote that could replace the built-in prompt(). It uses adobe's implementation of scriptUI to handle the UI.
- Mark
var pastedValues = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
alert(pastedValues + "has a leng
...
Copy link to clipboard
Copied
Hi @m1cmdrpitch, here is a function I wrote that could replace the built-in prompt(). It uses adobe's implementation of scriptUI to handle the UI.
- Mark
var pastedValues = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
alert(pastedValues + "has a length of " + pastedValues.length);
pastedValues = prompter(pastedValues, 'Prompter test', 'Paste string here:');
if (pastedValues != undefined)
alert(pastedValues + "has a length of " + pastedValues.length);
function prompter(obj, title, message) {
title = title || '';
return (function () {
var result;
if (obj instanceof Array) { obj = obj.join('\r') };
var w = new Window('dialog', title);
if (message != undefined)
w.add('statictext', undefined, message, { alignment: 'left' });
var textArea = w.add('edittext', undefined, obj, { multiline: true, scrolling: true });
textArea.maximumSize.height = w.maximumSize.height - 100;
textArea.minimumSize.height = 150;
textArea.minimumSize.width = 500;
var button = w.add('button', undefined, 'Done', { name: 'ok' });
button.onClick = function (ev) {
result = textArea.text;
w.close(1);
};
if (w.show() == 1) return result;
})();
}
Copy link to clipboard
Copied
That prompter function looks and works great, scrollable and multi-lined are nice UX upgrades.
Just for documentation purposes here is what that function produces:
Thanks.