inputQuery
Revision as of 23:51, 10 July 2025 by Leunsel (talk | contribs) (Created page with "Category:Lua '''function''' inputQuery(''Caption'', ''Prompt'', ''InitialString'') ''':''' String or nil Displays a dialog box that prompts the user to input a string....")
function inputQuery(Caption, Prompt, InitialString) : String or nil
Displays a dialog box that prompts the user to input a string. Returns the entered string, or nil if the user cancels the dialog.
Function Parameters
| Parameter | Type | Description |
|---|---|---|
| Caption | String | The title of the input dialog window. |
| Prompt | String | The prompt or question to display to the user. |
| InitialString | String | The default value shown in the input field. |
Examples
-- Ask the user for their name
local name = inputQuery("User Name", "Please enter your name:", "")
if name then
showMessage("Hello, " .. name .. "!")
else
showMessage("You cancelled the input.")
end
-- Prompt for a file name with a default value
local filename = inputQuery("Save File", "Enter the file name to save:", "myfile.txt")
if filename then
print("Saving to: " .. filename)
end
-- Use inputQuery for a password (not masked)
local password = inputQuery("Authentication", "Enter your password:", "")
if password then
print("Password entered.")
end