Adds a dialog into your app.
Properties
These are the setter and getter properties for the addDialog Component.
Example - Basic
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")
this.btn = ui.addButton(this.main, "Show Dialog", "Contained,Primary")
this.btn.setOnTouch( this.showDialog )
var bodyText = "Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running."
this.dlg = ui.addDialog("Use Google's location service?", bodyText, "Disagree,Agree")
}
showDialog()
{
this.dlg.show()
}
}
from hybrid import ui
def OnStart():
global dlg
main = ui.addLayout("main", "Linear", "VCenter,FillXY")
btn = ui.addButton(main, "Show Dialog", "Contained,Primary")
btn.setOnTouch(showDialog)
bodyText = "Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running."
dlg = ui.addDialog("Use Google's location service?", bodyText, "Disagree,Agree")
def showDialog(event):
dlg.show()
Example - NoCancel
class Main extends App
{
onStart()
{
this.main = ui.addLayout( "main", "Linear", "VCenter,FillXY")
this.btn = ui.addButton( this.main, "Show Dialog", "Contained,Primary" )
this.btn.setOnTouch( this.showDialog )
var bodyText = "Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running."
this.dlg = ui.addDialog( "Use Google's location service?", bodyText, "Close,Agree", "NoCancel" )
this.dlg.setOnAction( this.onAction );
}
showDialog()
{
this.dlg.show();
}
onAction( action )
{
if(action == "Close")
{
ui.showPopup("There you go.");
this.dlg.hide();
}
else
{
ui.showPopup("Oops! You can't close me here.");
}
}
}
from hybrid import ui
def OnStart():
global dlg
main = ui.addLayout("main", "Linear", "VCenter,FillXY")
btn = ui.addButton(main, "Show Dialog", "Contained,Primary")
btn.setOnTouch(showDialog)
bodyText = "Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running."
dlg = ui.addDialog("Use Google's location service?", bodyText, "Close,Agree", "NoCancel")
dlg.setOnAction(onAction)
def showDialog(event):
dlg.show()
def onAction(action, index):
if action == "Close":
ui.showPopup("There you go.")
dlg.hide()
else:
ui.showPopup("Oops! You can't close me here.")
Example - Adding controls to the dialog
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")
this.main.setChildMargins(0.01, 0.01, 0.01, 0.01)
this.txt = ui.addText(this.main, "Email: ", "", 0.7)
this.btn = ui.addButton(this.main, "Show Dialog", "Contained,Primary")
this.btn.setOnTouch( this.showDialog )
var bodyText = "To subscribe to this website, please enter your email address here. We will send updates occasionally."
this.dlg = ui.addDialog("Subscribe", bodyText, "Cancel,Subscribe")
this.dlg.setOnAction( this.onAction )
this.tfd = ui.addTextField(this.dlg.layout, "", "Filled")
this.tfd.label = "Email Address"
}
showDialog()
{
this.dlg.show()
}
onAction( action )
{
if( action == "Subscribe" )
{
this.txt.text = "Email : " + this.tfd.text
}
}
}
from hybrid import ui
def OnStart():
global dlg, txt, tfd
main = ui.addLayout("main", "Linear", "VCenter,FillXY")
main.setChildMargins(0.01, 0.01, 0.01, 0.01)
txt = ui.addText(main, "Email: ", "", 0.7)
btn = ui.addButton(main, "Show Dialog", "Contained,Primary")
btn.setOnTouch(showDialog)
bodyText = "To subscribe to this website, please enter your email address here. We will send updates occasionally."
dlg = ui.addDialog("Subscribe", bodyText, "Cancel,Subscribe")
dlg.setOnAction(onAction)
tfd = ui.addTextField(dlg.layout, "", "Filled")
tfd.label = "Email Address"
def showDialog(event):
dlg.show()
def onAction(action, index):
if action == "Subscribe":
txt.text = "Email: " + tfd.text
Methods
The following methods are available on the Dialog object: