Canvas MessageBox: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{| class="wikitable" |- ! Icon !! Icon Name !! Standard MessageBox !! Description |- | link= || <code>"dialog-question"</code> || <syntaxhighlight...") |
(First proper version. Examples, Severity levels...) |
||
Line 1: | Line 1: | ||
{| class="wikitable" | Message boxes provide a simple way to report information and warnings or ask questions. In FlightGear 3.1+ using <code>canvas.MessageBox</code> with the Nasal scripting language, allows showing standard message boxes to the user. | ||
== Predefined Severity Levels/Icons == | |||
{| class="wikitable" style="width:100%" | |||
|- | |- | ||
! Icon !! Icon Name !! Standard MessageBox !! Description | ! Icon !! Icon Name !! Standard MessageBox !! Description | ||
|- | |- | ||
| [[File:Dialog-question.png|link=]] || <code>"dialog-question"</code> || <syntaxhighlight lang="nasal">canvas.MessageBox.question(title, text, cb = nil, buttons = | | style="text-align:center;" | [[File:Dialog-question.png|link=]] || <code>"dialog-question"</code> || <syntaxhighlight lang="nasal">canvas.MessageBox.question( | ||
<title>, | |||
<text>, | |||
cb = nil, | |||
buttons = canvas.MessageBox.Yes | |||
| canvas.MessageBox.No | |||
);</syntaxhighlight> || Ask the user a (yes/no) question. | |||
|- | |- | ||
| [[File:Dialog-info.png|link=]] || "dialog-info" || | | style="text-align:center;" | [[File:Dialog-info.png|link=]] || <code>"dialog-info"</code> || <syntaxhighlight lang="nasal">canvas.MessageBox.information( | ||
<title>, | |||
<text>, | |||
cb = nil, | |||
buttons = canvas.MessageBox.Ok | |||
);</syntaxhighlight> || Show the user some information, with only the possiblity to close the dialog. | |||
|- | |- | ||
| [[File:Dialog-warning.png|link=]] || "dialog-warning" || | | style="text-align:center;" | [[File:Dialog-warning.png|link=]] || <code>"dialog-warning"</code> || <syntaxhighlight lang="nasal">canvas.MessageBox.warning( | ||
<title>, | |||
<text>, | |||
cb = nil, | |||
buttons = canvas.MessageBox.Ok | |||
);</syntaxhighlight> || Show the user a non critical warning, with only the possiblity to close the dialog. | |||
|- | |- | ||
| [[File:Dialog-error.png|link=]] || "dialog-error" || | | style="text-align:center;" | [[File:Dialog-error.png|link=]] || <code>"dialog-error"</code> || <syntaxhighlight lang="nasal">canvas.MessageBox.critical( | ||
<title>, | |||
<text>, | |||
cb = nil, | |||
buttons = canvas.MessageBox.Ok | |||
);</syntaxhighlight> || Notify the user of a critical error or failure, with only the possiblity to close the dialog. | |||
|} | |||
== Examples == | |||
{| style="width:100%" | |||
|- style="vertical-align:top;" | |||
| [[File:Canvas-MessageBox-demo information.png|link=]] || | |||
<syntaxhighlight lang="nasal"> | |||
canvas.MessageBox.info("Success", "The operation has successfully completed."); | |||
</syntaxhighlight> | |||
|- style="vertical-align:top;" | |||
| [[File:Canvas-MessageBox-demo question.png|link=]] || | |||
<syntaxhighlight lang="nasal"> | |||
canvas.MessageBox.question( | |||
"Do you want it?", | |||
"The question is: Do you want to get a real question?.", | |||
func(sel) | |||
{ | |||
if( sel == canvas.MessageBox.Yes ) | |||
print("I only know that the answer is 42."); | |||
else | |||
print("Ok, I will not give you a real question."); | |||
} | |||
); | |||
</syntaxhighlight> | |||
|- style="vertical-align:top;" | |||
| [[File:Canvas-MessageBox-demo warning dont-show-again.png|link=]] || | |||
<syntaxhighlight lang="nasal"> | |||
canvas.MessageBox.warning( | |||
"Warning...", | |||
"Have you read this warning? If you want it will not be shown again.", | |||
func(sel) | |||
{ | |||
if( sel != canvas.MessageBox.Ok ) | |||
return; | |||
print("You have been warned. Let the games begin..."); | |||
}, | |||
canvas.MessageBox.Ok | |||
| canvas.MessageBox.Cancel | |||
| canvas.MessageBox.DontShowAgain | |||
); | |||
</syntaxhighlight> | |||
|} | |} |
Revision as of 15:51, 23 June 2014
Message boxes provide a simple way to report information and warnings or ask questions. In FlightGear 3.1+ using canvas.MessageBox
with the Nasal scripting language, allows showing standard message boxes to the user.
Predefined Severity Levels/Icons
Icon | Icon Name | Standard MessageBox | Description |
---|---|---|---|
"dialog-question" |
canvas.MessageBox.question(
<title>,
<text>,
cb = nil,
buttons = canvas.MessageBox.Yes
| canvas.MessageBox.No
); |
Ask the user a (yes/no) question. | |
"dialog-info" |
canvas.MessageBox.information(
<title>,
<text>,
cb = nil,
buttons = canvas.MessageBox.Ok
); |
Show the user some information, with only the possiblity to close the dialog. | |
"dialog-warning" |
canvas.MessageBox.warning(
<title>,
<text>,
cb = nil,
buttons = canvas.MessageBox.Ok
); |
Show the user a non critical warning, with only the possiblity to close the dialog. | |
"dialog-error" |
canvas.MessageBox.critical(
<title>,
<text>,
cb = nil,
buttons = canvas.MessageBox.Ok
); |
Notify the user of a critical error or failure, with only the possiblity to close the dialog. |
Examples
canvas.MessageBox.info("Success", "The operation has successfully completed."); | |
canvas.MessageBox.question(
"Do you want it?",
"The question is: Do you want to get a real question?.",
func(sel)
{
if( sel == canvas.MessageBox.Yes )
print("I only know that the answer is 42.");
else
print("Ok, I will not give you a real question.");
}
); | |
canvas.MessageBox.warning(
"Warning...",
"Have you read this warning? If you want it will not be shown again.",
func(sel)
{
if( sel != canvas.MessageBox.Ok )
return;
print("You have been warned. Let the games begin...");
},
canvas.MessageBox.Ok
| canvas.MessageBox.Cancel
| canvas.MessageBox.DontShowAgain
); |