AutocloseAlert, CustomConfirm, and CustomPrompt Messages
I found this thread: https://community.adobe.com/t5/illustrator-discussions/auto-close-alert-message/td-p/9398258
Images here: https://github.com/Marshall-Brooks/Sandbox/issues/2
See also:
I'm somewhat spoiled by the Enhanced Message Box add-on for Microsoft Access which shows a standard Msgbox with a countdown of seconds until the box closes.
I used @Peter Kahrel's Scipt UI guide to modify the first linked script as follows:
function AutocloseAlert(message, delaySeconds, title){
title = title || 'Alert';
var alertWindow = new Window('palette', title);
// var control_text = alertWindow.add('edittext', [0, 0, 500, 200], message, {multiline: true});
// var control_text = alertWindow.add('edittext', , message, {multiline: true});
var control_text = alertWindow.add('edittext', undefined, message, {multline:true})
// if(delaySeconds === 0){
var control_close = alertWindow.add('button', undefined, 'OK');
control_close.onClick = function(){
if(alertWindow){
alertWindow.hide();
alertWindow = null;
}
};
// }
alertWindow.show();
alertWindow.update();
if(delaySeconds > 0){
$.sleep(delaySeconds * 1000);
alertWindow.hide();
alertWindow = null;
}
}I'm having the following issues:
- I don't like that the window shows grayed out (disabled) - presumably b/c of the sleep function. I'd prefer it to look like the zero second but disappear when I clicked OK or when the timer expired. I tried commenting out the line "$.Sleep(DelaySeconds * 1000) and replacing it with:
var startTime = new Date().getTime();
while ( new Date().getTime() - startTime < delaySeconds * 1000 ) {alertWindow.update()} But it didn't change how it worked - i.e. the window was still grayed out, and clicking the OK button did not close the window, but it did disappear after the delaySeconds interval.
- I would prefer to have the OK button show the seconds remaining, but I think I need two timers for this and I'm not sure how to implement them.
- Probably easiest - I'd prefer to have a minimum size for the window and a maximum before it wraps to two lines, but I can basically set my "message" text to achieve this. (An alert that is more than one line is probably too long anyway).
Thank you in advance!!!
