Difference between revisions of "UI.SimpleTextInput"

From Nomad DB
(Created page with "Shows a UI dialog which allows the user to enter text. The input can be confirmed by pressing Enter, the dialog can be closed with ESC key. == Syntax == <syntaxhighlight lang...")
 
Line 1: Line 1:
 +
[[File:UISimpleTextInput.png|thumb]]
 
Shows a UI dialog which allows the user to enter text. The input can be confirmed by pressing Enter, the dialog can be closed with ESC key.
 
Shows a UI dialog which allows the user to enter text. The input can be confirmed by pressing Enter, the dialog can be closed with ESC key.
  
== Syntax ==
+
==Syntax==
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
UI.SimpleTextInput(title, callback[, infoText])
 
UI.SimpleTextInput(title, callback[, infoText])
 
</syntaxhighlight>
 
</syntaxhighlight>
* '''title:''' string (Title Text)
+
 
* '''callback:''' function (success: boolean, text: string)
+
*'''title:''' string (Title Text)
* '''infoText:''' string (optional) Text below the Input field
+
*'''callback:''' function (success: boolean, text: string)
 +
*'''infoText:''' string (optional) Text below the Input field
  
 
If the dialog was canceled by the user, success is false and text is 'nil'. The dialog is automatically cancelled if the user opens the Console or any other UI menus.
 
If the dialog was canceled by the user, success is false and text is 'nil'. The dialog is automatically cancelled if the user opens the Console or any other UI menus.
  
== Example ==
+
==Example==
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
UI.SimpleTextInput("Enter your name", function(success, text)
 
UI.SimpleTextInput("Enter your name", function(success, text)
Line 22: Line 24:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== Related Pages ==
+
==Related Pages==
* [[UI.SimpleMenu]]
+
 
 +
*[[UI.SimpleMenu]]
  
 
[[Category:WD2 ScriptHook Lua]]
 
[[Category:WD2 ScriptHook Lua]]

Revision as of 22:00, 2 August 2020

UISimpleTextInput.png

Shows a UI dialog which allows the user to enter text. The input can be confirmed by pressing Enter, the dialog can be closed with ESC key.

Syntax

UI.SimpleTextInput(title, callback[, infoText])
  • title: string (Title Text)
  • callback: function (success: boolean, text: string)
  • infoText: string (optional) Text below the Input field

If the dialog was canceled by the user, success is false and text is 'nil'. The dialog is automatically cancelled if the user opens the Console or any other UI menus.

Example

UI.SimpleTextInput("Enter your name", function(success, text)
	if success then
		print("Your name is: ", text)
	else
		print("Dialog was canceled")
	end
end)

Related Pages