Difference between revisions of "AlertDialog"

From GiderosMobile
m (added see also)
m (Text replacement - "</source" to "</syntaxhighlight")
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
local alertDialog = AlertDialog.new("This is my title", "And my message", "Cancel", "Yes", "No")
 
local alertDialog = AlertDialog.new("This is my title", "And my message", "Cancel", "Yes", "No")
 
local function onComplete(e)
 
local function onComplete(e)
Line 22: Line 22:
 
alertDialog:addEventListener(Event.COMPLETE, onComplete)
 
alertDialog:addEventListener(Event.COMPLETE, onComplete)
 
alertDialog:show()
 
alertDialog:show()
</source>
+
</syntaxhighlight>
  
 
=== See also ===
 
=== See also ===

Latest revision as of 16:59, 12 July 2023

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2012.8
Inherits from: Object

Description

The AlertDialog class is used to display native alert dialogs with one, two or three buttons.

Cancel button is mandatory but other two buttons are optional.

When the user presses any button in the alert dialog, it's dismissed and AlertDialog_Event.COMPLETE event is dispatched.

If alert dialog is dismissed by any other means (pressing back button on Android or pressing close button on desktop), it behaves as cancel button pressed.

Example

local alertDialog = AlertDialog.new("This is my title", "And my message", "Cancel", "Yes", "No")
local function onComplete(e)
	print(e.buttonIndex, e.buttonText)
end
alertDialog:addEventListener(Event.COMPLETE, onComplete)
alertDialog:show()

See also

TextInputDialog

Methods

AlertDialog.new creates a new AlertDialog object

AlertDialog:hide hides the alert dialog
AlertDialog:show shows the alert dialog

Events

AlertDialog_Event.COMPLETE

Constants