AlertDialog Event.COMPLETE: Difference between revisions

From GiderosMobile
No edit summary
added example because imho it was needed here
Line 4: Line 4:
<source lang="lua">
<source lang="lua">
Event.COMPLETE = "complete"
Event.COMPLETE = "complete"
</source>
=== <translate>Example</translate> ===
<source lang="lua">
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()
</source>
</source>


=== Event properties: ===
=== Event properties: ===
'''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. ''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.


{{AlertDialog}}
{{AlertDialog}}

Revision as of 03:57, 4 January 2020

This event is dispatched when user presses any button on AlertDialog or the dialog is dismissed by any other reason.

Event.COMPLETE = "complete"

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.