Custom Message Boxes
Feature Definitions offer a powerful way to streamline your workflow and customize user input fields. You can use message boxes in CAESES to create pop-up windows that provide more information, require an action by the user or that can warn in case of critical input values. Message boxes allow validating input or computation values, or promote more conscious user interaction.
General Syntax
This is the general syntax of the warning message box:
msgBoxWarning(Caption, Text, Button1 Text, Button2 Text, Button3 Text, Default Button)
| Syntax | Type | Description |
|---|---|---|
| Caption | FString | Header of the message box |
| Text | FString | Main message text of the message box |
| Button 1 | FString | Text of the first button from the left |
| Button 2 | FString | Text of the second button from the left |
| Button 3 | FString | Text of the third button from the left. You can keep this as empty string "" to ignore this button |
| Default Button | FString | Underlined default button, which is active, when you press enter |
Return Type
The return type of the command is an FUnsigned based on the selected button.
| Button | Return Value |
|---|---|
| Button 1 | 0 |
| Button 2 | 1 |
| Button 3 | 2 |
| Close (x) | value of last active button |
You can store the return value in an unsigned variable in order to use that in conditional statements:
FUnsigned val (msgBoxWarning(Caption,Text,Button1 Text,Button2 Text,Button3 Text,Default Button))
if(val == 0)
echo("do this")
elseif(val == 1)
echo("do that")
elseif(val == 2)
echo("do this and that")
else
echo("do nothing")
endif
Box Types
There are different box types for various scenarios:
Information Box
Example Code:
msgBoxInformation("For your Information","The feature input seems to be very good. Good Job!","Thank you","","",1)
Warning Box
Example Code:
msgBoxWarning("Warning","The input value of \"Number of Blades\" seems to be very high. Do you want to continue?","Continue","Cancel","",1)
Question Box
Example Code:
msgBoxWarning("Question","Is the value " + 5 +" correct?","Yes","No","",1)
Critical Box
Example Code:
msgBoxCritical("Attention","Some calculations returned an unreasonable value.","Continue","Cancel","",1)
Text Formatting
It is possible to format the text using HTML in order to have, e.g., a colored text. Therefore you can process the text in a function that allows reusing your formatted style:
function redText(FString text) : FString
FString res("<font color=\"red\"> " + text + "</font>")
return (res)
endfunction
msgBoxWarning("Warning",redText("The input value of \"Number of Blades\" seems to be very high. Do you want to continue?"),"Continue","Cancel","",1)