Zeige den Standarddialog mit einer Nachricht und bis zu drei Antwortmöglichkeiten.
Zeige den Standarddialog mit einer Nachricht und bis zu drei Antwortmöglichkeiten.
Bis Version 3.2 R2299 ist die Ausgabelänge (nach dem Ersetzen aller %-Markierungen) auf 9999 Zeichen beschränkt. Längere Ergebnisstrings können zu Fehlverhalten oder Absturz von InDesign® führen.
Im Bild sehen Sie die Nummerierung der Buttons.
Unter Windows können Sie die Anweisung nur eingeschränkt verwenden. Hier die Erklärung von Adobe :
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.
Einen Dialog mit zwei Button können sie mit den Button-Labels "OK", "Cancel", "" (in genau dieser Schreibweise) erhalten. Einen Dialog mit drei Buttons konnten wir unter Windows nicht erzeugen.
Name | Typ | Default | Beschreibung |
Return | int | Welches Button wurde geklickt? Im Bild oben sehen Sie, welches Ergebnis jedes Button liefert. | |
button1, button2, button3 | String oder char*, String oder char*, String oder char* | -, -, - | Beschriftung der Buttons. Die Strings werden, wenn möglich, ersetzt. Die Angaben dürfen leer (0 oder "") sein nach folg. Schema: "button1", "button2", 0 : Button 3 fehlt "button1", 0, 0 : Button 2 und 3 fehlen 0, 0, 0 : Button1 wird zu "Okay" |
defaultButton | int | - | Welches Button soll das Default-Button sein? Verwenden Sie die im Bild angegebenen Nummern. |
iconID | int | - | Im Dialog gezeigtes Icon 0 : Kein Icon 1 : Information 2 : Warnung 3 : Fehler 4 : Frage |
formatStr | String oder char* | - | Nachricht. Die Nachricht darf Format-Tags enthalten, mehr dazu dazu siehe hier. Für jeden %-Marker wird (in der richtigen Reihenfolge und vom richtigen Datentyp) eine weitere Eingabevariable erwartet. |
... | Abhängig von den Markierungen | - | Werte oder Variablen gemäß den %-Tags im Formatstring |
Mit übersetzungen für "Button1, ... in einer der gültigen message_deDE.xml-Dateien erhalten Sie aus dem Text eines Rahmens den gezeigten Dialog.
int main () { int r;
r = alert ( "1", "2", "3", 1, 4, "Der Dialog gibt die in den Buttons gezeigten Zahlen zurück");
showmessage ("# : %d\n", r);
return 0; }
Alert mit String anstatt char *
int main () { String content = string::alloc("Sind Sie sicher?"); String yes = string::alloc("Ja"); String no = string::alloc("Nein"); String maybe = string::alloc("Vielleicht");
alert(yes, no, maybe, 0, 0, content);
string::release(content); string::release(yes); string::release(no); string::release(maybe);
return 0; }
Alphabetic index HTML hierarchy of classes or Java