int alert (
char* button1,
char* button2,
char* button3,
int defaultButton,
int iconID,
char* formatStr,
...)
Display the standard dialog with a message and up to three buttons to answer.
Documentation
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 : QuestionformatStr 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 = alertDisplay the standard dialog with a message and up to three buttons to answer. ( "Button1", "Button2", "Button3", 1, 4, "The dialog returns the values shown in the buttons."); showmessageDisplay the standard dialog with a message. ("# Alert result : %d\n", r); return 0; }
Alert with String instead of char *
int main () { StringExport Comet notes of a document. Be careful with destString, its a String not a char*. content = string::allocCreate a new self-managing string. The object must be deleted again using string::release.("Are you sure?"); StringExport Comet notes of a document. Be careful with destString, its a String not a char*. yes = string::allocCreate a new self-managing string. The object must be deleted again using string::release.("Yes"); StringExport Comet notes of a document. Be careful with destString, its a String not a char*. no = string::allocCreate a new self-managing string. The object must be deleted again using string::release.("No"); StringExport Comet notes of a document. Be careful with destString, its a String not a char*. maybe = string::allocCreate a new self-managing string. The object must be deleted again using string::release.("Maybe"); alertDisplay the standard dialog with a message and up to three buttons to answer.(yes, no, maybe, 0, 0, content); string::releaseDelete a string object created using string::alloc(content); string::releaseDelete a string object created using string::alloc(yes); string::releaseDelete a string object created using string::alloc(no); string::releaseDelete a string object created using string::alloc(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
© Copyright 2003-2024 WERK II GmbH Duisburg |
This documentation is part of the priint:comet InDesign®, InDesign Server® and Illustrator® plug-in and of the comet_pdf packages and is subject to the same license terms as priint:comet itself. The documentation may neither be passed on nor installed on public servers without the consent of WERK II GmbH. The documentation describes the priint:comet scripting language cScript and provides support for solving technical problems when using the priint:comet plugins. The documentation is not a manual for the priint:comet plugins. A manual of the priint:comet plugins can be found here. The documentation has been prepared with the greatest possible care. In case of errors or hints, please do not hesitate to contact our support. However, faulty or incomplete functional descriptions shall in no case result in an obligation on the part of WERK II GmbH to adapt the described item. This copyright notice may not be removed or altered. |