AlertDialog Event.COMPLETE: Difference between revisions
From GiderosMobile
added example because imho it was needed here |
m Text replacement - "<source" to "<syntaxhighlight" |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
< | '''Available since:''' Gideros 2012.8<br/> | ||
'''Value:''' complete<br/> | |||
'''Defined by:''' [[AlertDialog]]<br/> | |||
=== Description === | |||
This event is dispatched when user presses any button on AlertDialog or the dialog is dismissed by any other reason. | This event is dispatched when user presses any button on AlertDialog or the dialog is dismissed by any other reason. | ||
=== Example === | |||
<syntaxhighlight lang="lua"> | |||
local alertDialog = AlertDialog.new("Title", "Message", "CANCEL", "YES", "NO") | |||
=== | |||
< | |||
local alertDialog = AlertDialog.new("Title", "Message", " | |||
local function onComplete(event) | local function onComplete(event) | ||
| Line 16: | Line 16: | ||
alertDialog:addEventListener(Event.COMPLETE, onComplete) | alertDialog:addEventListener(Event.COMPLETE, onComplete) | ||
alertDialog:show() | alertDialog:show() | ||
</ | </syntaxhighlight> | ||
=== Event properties | === Event properties === | ||
'''buttonIndex:''' (number) the index of the button pressed. ''nil'' when Cancel button is pressed, ''1'' when 1st button is pressed and, ''2'' when 2nd button is pressed | '''buttonIndex:''' (number) the index of the button pressed. ''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 | '''buttonText:''' (string) the text of the button pressed<br/> | ||
{{AlertDialog}} | {{AlertDialog}} | ||
Latest revision as of 15:55, 12 July 2023
Available since: Gideros 2012.8
Value: complete
Defined by: AlertDialog
Description
This event is dispatched when user presses any button on AlertDialog or the dialog is dismissed by any other reason.
Example
local alertDialog = AlertDialog.new("Title", "Message", "CANCEL", "YES", "NO")
local function onComplete(event)
print(event.buttonIndex, event.buttonText)
end
alertDialog:addEventListener(Event.COMPLETE, onComplete)
alertDialog:show()
Event properties
buttonIndex: (number) the index of the button pressed. 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