Difference between revisions of "TextInputDialog Event.COMPLETE"

From GiderosMobile
(Created page with "'''<translate>Available since</translate>:''' Gideros 2012.8<br/> '''<translate>Value</translate>:''' complete<br/> '''<translate>Defined by</translate>:''' Special:MyLangua...")
 
 
Line 1: Line 1:
'''<translate>Available since</translate>:''' Gideros 2012.8<br/>
+
'''Available since:''' Gideros 2012.8<br/>
'''<translate>Value</translate>:''' complete<br/>
+
'''Value:''' complete<br/>
'''<translate>Defined by</translate>:''' [[Special:MyLanguage/TextInputDialog|TextInputDialog]]<br/>
+
'''Defined by:''' [[TextInputDialog]]<br/>
  
 
=== Description ===
 
=== Description ===
This event is dispatched when user presses any button on TextInputDialog or the dialog is dismissed by any other reason.
+
This event is dispatched when user presses any button on a TextInputDialog or the dialog is dismissed by any other means.
  
 
=== Parameters ===
 
=== Parameters ===
 
'''text''': (string) the text entered into text input field<br/>
 
'''text''': (string) the text entered into text input field<br/>
'''buttonIndex''': (number) the index of the button pressed. It is nil when cancel button is pressed, 1 when 1st button is pressed and 2 when 2nd button is pressed.<br/>
+
'''buttonIndex''': (number) the index of the button pressed. It is nil when ''cancel'' button is pressed, 1 when ''1st button'' is pressed and 2 when ''2nd button'' is pressed<br/>
 
'''buttonText''': (string) the text of the button pressed<br/>
 
'''buttonText''': (string) the text of the button pressed<br/>
 +
 +
=== Example ===
 +
<syntaxhighlight lang="lua">
 +
local textInputDialog = TextInputDialog.new("my title", "my message", "some text", "Cancel", "OK")
 +
 +
local function onComplete(event)
 +
print(event.text, event.buttonIndex, event.buttonText)
 +
end
 +
 +
textInputDialog:addEventListener(Event.COMPLETE, onComplete)
 +
textInputDialog:show()
 +
</syntaxhighlight>
  
 
{{TextInputDialog}}
 
{{TextInputDialog}}

Latest revision as of 10:40, 26 August 2024

Available since: Gideros 2012.8
Value: complete
Defined by: TextInputDialog

Description

This event is dispatched when user presses any button on a TextInputDialog or the dialog is dismissed by any other means.

Parameters

text: (string) the text entered into text input field
buttonIndex: (number) the index of the button pressed. It is nil when cancel button is pressed, 1 when 1st button is pressed and 2 when 2nd button is pressed
buttonText: (string) the text of the button pressed

Example

local textInputDialog = TextInputDialog.new("my title", "my message", "some text", "Cancel", "OK")

local function onComplete(event)
	print(event.text, event.buttonIndex, event.buttonText)
end

textInputDialog:addEventListener(Event.COMPLETE, onComplete)
textInputDialog:show()