Difference between revisions of "TextInputDialog:setInputType"
From GiderosMobile
Line 4: | Line 4: | ||
=== Description === | === Description === | ||
− | Sets the input (keyboard) type associated with the text field. | + | Mostly used on mobile devices. Sets the input (keyboard) type associated with the text field. |
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
TextInputDialog:setInputType(type) | TextInputDialog:setInputType(type) | ||
Line 18: | Line 18: | ||
=== Parameters === | === Parameters === | ||
'''type''': (string) input type associated with the text field<br/> | '''type''': (string) input type associated with the text field<br/> | ||
+ | |||
+ | === Example === | ||
+ | '''Mobile''' | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | local textInputDialog = TextInputDialog.new("my title", "my message", 360, "Cancel", "OK") | ||
+ | textInputDialog:setInputType(TextInputDialog.NUMBER) -- or "number" | ||
+ | |||
+ | 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 20:51, 4 November 2024
Available since: Gideros 2012.8
Class: TextInputDialog
Description
Mostly used on mobile devices. Sets the input (keyboard) type associated with the text field.
TextInputDialog:setInputType(type)
The options are:
- TextInputDialog.TEXT: default keyboard type
- TextInputDialog.NUMBER: numeric keypad
- TextInputDialog.PHONE: keypad designed for entering telephone numbers
- TextInputDialog.EMAIL: keyboard optimized for specifying email addresses
- TextInputDialog.URL: keyboard optimized for URL entry
Parameters
type: (string) input type associated with the text field
Example
Mobile
local textInputDialog = TextInputDialog.new("my title", "my message", 360, "Cancel", "OK")
textInputDialog:setInputType(TextInputDialog.NUMBER) -- or "number"
local function onComplete(event)
print(event.text, event.buttonIndex, event.buttonText)
end
textInputDialog:addEventListener(Event.COMPLETE, onComplete)
textInputDialog:show()