Skip to content

CAU_UserInputMenus_fnc_text

ConnorAU edited this page Nov 29, 2022 · 6 revisions

Description:

Create a text dialog for a user to provide text input, then execute code with their text input as the argument.

Arguments:

Parameters : Array - Data applied to the display when created
    0. Multiline: Bool (Optional, default: false) - Single or Multiline dialog
    1. Start Text: String (Optional) - Text printed to the edit control when the display opens
Title: String (Optional)
Button Clicked Code: Code OR Array (Optional)
    If Array, format is [Code,Any] where Any is arguments provided as _this
    Special Variables:
        _confirmed: Bool - true if user clicked confirm button, false if they clicked cancel button
        _text: String - Contents of the text input control
Button Confirm Text: String (Optional) - Default "Ok"
Button Cancel Text: String (Optional) - Default "Cancel". If not defined, the cancel option will be disabled
Parent Display: Display (Optional) - Used when you need to force the dialog to open on top of a display

Example 1:

[
    [true,""],
    "Send alert to all players",
    {
        if _confirmed then {
            systemchat format["Message content: %1",_text];
        } else {
            systemchat "Message cancelled";
        };
    },
    "Send",
    ""  // reverts to default
] call CAU_UserInputMenus_fnc_text;

Example1.png

Example 2:

// Disable cancel option
[
    [false,""],
    "Name a flavour of ice-cream",
    {
        systemchat format["Submitted flavour: %1",_text];
    },
    "Submit"
] call CAU_UserInputMenus_fnc_text;

Example2.png