Display the standard dialog with a message and up to three buttons to answer.

Display the standard dialog with a message and up to three buttons to answer.

In plug-in versions prior 3.2 R2300 the output length (after all %-markers are replaced) is limited to 9999. Longer strings may crash InDesign®.

See here for button numbers:

Under Windows the function is not fully supported. Here are the Adobe comments to the internal function ModalAlert, that is called by alert:

ModalAlert is really the all-powerful alert function. ModalAlert lets you build a dynamically sized alert (based on the length of the message) that can have an optional icon and up to three buttons. Furthermore, the function lets you specify which button is the "default" button.

ModalAlert can display an alert with one, two, or three buttons. There is a PMString title for each string. Pass in "kNullString" for no button. DO NOT CALL TRANSLATE on any of the button strings. ModalAlert will automatically Translate all of the strings, including the message.

WARNING for Windows only: Presently, CAlert relies on the platform alert mechanism to display the dialog. Windows is weak in the titles of the buttons permitted in the alerts. Only the standard Yes, No, Cancel, OK buttons are supported. This explains why when a program crashes, you get a dialog that says something like, "Hit OK to quit or Cancel to debug the application" rather than an alert with two buttons such as "Debug" and "Quit."

Unfortunately, our Windows alert mechanism is saddled with these same limitations. That means that on Windows, you can't use custom button strings and any custom keyboard shortcut resource is ignored. I suppose if we had time, we could write our own implementation of Windows alerts. However, it appears that Windows users are used to alerts with only limited button names. If this is a severe limitation, come talk to me. Tom Taylor.

Note on linefeeds: The platform will break lines in the alert where it sees fit. On the Mac this works pretty well. On Windows, you can get some long skinny alerts. If you want more control, you can compose strings with carriage returns in them. To do this, use the kLineSeparatorString define in CoreResTypes.h. A sample string in a .fr file might look like this: e.g. "Here is a string" kLineSeparatorString "that takes up two lines." Resource compiler will combine into one string with a carriage return.


To get a two buttons dialog, use the button labels "OK", "Cancel", "" (exactly written like this). We were not able to produce a three button dialog.

Name Type Default Description
Return int   Number of clicked button, see above image.
button1, button2, button3 String or char*, String or char*, String or char* -, -, - Labels of buttons or "" or 0 if button not required. Labels are translated automatically.
defaultButton int - Number of default button, see above image.
iconID int - Icon of dialog

0 : No icon
1 : Information
2 : Warning
3 : Error
4 : Question
formatStr String or char* - Message. The string can contain %-markes , see here to learn more. An additional parameter is expected in the (correct) sequence and with the correct type for each of these markers.
... Depending on the %-markers - Values or variables according to the %-markers in formatStr

int main ()
{
    int			r;
r = alert (   "Button1",   "Button2",   "Button3",   1,   4,   "The dialog returns the values shown in the buttons.");
showmessage ("# Alert result : %d\n", r);
return 0; }

Alert with String instead of char *

int main ()
{
    String 	content 	= string::alloc("Are you sure?");
    String 	yes 		= string::alloc("Yes");
    String 	no 			= string::alloc("No");
    String 	maybe 		= string::alloc("Maybe");
alert(yes, no, maybe, 0, 0, content);
string::release(content); string::release(yes); string::release(no); string::release(maybe);
return 0; }

Since
Version 3.2 R2266, 4. Feb. 2011

Available
priint:comet InDesign® Plug-Ins, comet_pdf

See Also
showmessage
translate

Alphabetic index HTML hierarchy of classes or Java