Home > HOT Posts!, InDesign Scripts > Scrollable alert

Scrollable alert

This is very great and handy script! If you have lot of text or numbers, regular alert dialog just roll text out of the screen, and you can’t see them. Here is an example from “ScriptUI for Dummies”, which is a more useful version of alert: it shows text in a scrollable window. An additional advantage is that you can copy text out of the alert. This was posted on Adobe’s InDesign scripting forum.

So, here is function:

function alert_scroll (title, input){
   if (input instanceof Array)
       input = input.join ("\r");
   var w = new Window ("dialog", title);
   var list = w.add ("edittext", undefined, input, {multiline: true, scrolling: true});
   list.maximumSize.height = w.maximumSize.height-100;
   list.minimumSize.width = 550;
   w.add ("button", undefined, "Close", {name: "ok"});
   w.show ();
}

Good thing in this script is that if you pass Array, it will be displayed in separate lines for each array object. Now let’s see how to pass data to script.

Pure text pass:

var myArray = 'Here is an example from "ScriptUI for Dummies", which is a more useful version of alert: it shows text in a scrollable window.';

Array case 1:

var myArray = app.documentPresets.everyItem().name;

Array case 2:

var myArray = Array("Item1","Item2","Item3","Item4","Item5");

Displaying result:

alert_scroll ("Alert!", myArray);

Function has two variables. First is for dialog title, and second is for Array that we are passing to function.

  1. No comments yet.
  1. December 29, 2010 at 14:44

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: