Difference between revisions of "AlertDialog"

From GiderosMobile
(removed language stuff and added e.text)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
 
<!-- GIDEROSOBJ:AlertDialog -->
 
<!-- GIDEROSOBJ:AlertDialog -->
 
+
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
+
'''Available since:''' Gideros 2012.8<br/>
'''<translate>Available since</translate>:''' Gideros 2012.8<br/>
+
'''Inherits from:''' [[Object]]<br/>
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Object|Object]]<br/>
 
  
 
=== Description ===
 
=== Description ===
Line 12: Line 10:
 
Cancel button is mandatory but other two buttons are optional.
 
Cancel button is mandatory but other two buttons are optional.
  
When the user presses any button in the alert dialog, it's dismissed and [[Special:MyLanguage/Event.COMPLETE|Event.COMPLETE]] event is dispatched.
+
When the user presses any button in the alert dialog, it's dismissed and '''[[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.
 
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.
Line 19: Line 17:
 
<source lang="lua">
 
<source 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(event)
+
local function onComplete(e)
print(event.buttonIndex, event.buttonText)
+
print(e.text, e.buttonIndex, e.buttonText)
 
end
 
end
 
alertDialog:addEventListener(Event.COMPLETE, onComplete)
 
alertDialog:addEventListener(Event.COMPLETE, onComplete)
Line 28: Line 26:
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
=== Methods ===
[[Special:MyLanguage/AlertDialog.new|AlertDialog.new]] ''creates a new AlertDialog object''<br/>
+
[[AlertDialog.new]] ''creates a new AlertDialog object''<br/><!--GIDEROSMTD:AlertDialog.new(title,message,cancelButton,button1,button2) creates a new AlertDialog object-->
<!-- GIDEROSMTD:AlertDialog.new(title,message,cancelButton,button1,button2) Creates a new AlertDialog object -->
 
  
[[Special:MyLanguage/AlertDialog:hide|AlertDialog:hide]] ''hides the alert dialog''<br/>
+
[[AlertDialog:hide]] ''hides the alert dialog''<br/><!--GIDEROSMTD:AlertDialog:hide() hides the alert dialog-->
<!-- GIDEROSMTD:AlertDialog:hide() Hides the alert dialog -->
+
[[AlertDialog:show]] ''shows the alert dialog''<br/><!--GIDEROSMTD:AlertDialog:show() shows the alert dialog-->
[[Special:MyLanguage/AlertDialog:show|AlertDialog:show]] ''shows the alert dialog''<br/>
 
<!-- GIDEROSMTD:AlertDialog:show() Shows the alert dialog -->
 
  
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Events</translate> ===
+
=== Events ===
<!--[[Special:MyLanguage/Event.COMPLETE|Event.COMPLETE]]<br/>-->
+
<!--[[Event.COMPLETE]]<br/>-->
[[Special:MyLanguage/AlertDialog_Event.COMPLETE|AlertDialog_Event.COMPLETE]]<br/>
+
[[AlertDialog_Event.COMPLETE]]<br/><!--GIDEROSEVT:Event.COMPLETE complete-->
<!-- GIDEROSEVT:Event.COMPLETE complete -->
+
=== Constants ===
=== <translate>Constants</translate> ===
 
 
|}
 
|}
  
 
{{GIDEROS IMPORTANT LINKS}}
 
{{GIDEROS IMPORTANT LINKS}}

Revision as of 10:34, 8 September 2021

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 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.text, e.buttonIndex, e.buttonText)
end
alertDialog:addEventListener(Event.COMPLETE, onComplete)
alertDialog:show()

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