The BlackBerry PlayBook has a BaseDialog class for generating modal dialogs, but does not allow developers to extend it for their own purposes. This leaves the PlayBook without a modal dialog for asking a question and receiving a response. As such I wrote one myself below, that as a parameter on the constructor, takes the name of the function responsible for removing this child, and working with the result.
import qnx.ui.core.UIComponent
import flash.display.Graphics
import flash.events.MouseEvent
import flash.events.Event
import flash.text.TextField
import flash.text.TextFormat
import flash.text.TextFormatAlign
import qnx.ui.text.TextInput
import qnx.ui.buttons.LabelButtonpublic class InputDialog extends UIComponent
{
public var inputText:TextInput = new TextInput();public function InputDialog(exitFunction:Function)
{
width = 1024
height = 600var myFormat:TextFormat = new TextFormat()
myFormat.color = 0x000000
myFormat.size = 32
myFormat.align = "center"var titleText:TextField = new TextField()
titleText.text = "Title"
titleText.width = 500
titleText.x = 260
titleText.y = 200
titleText.setTextFormat(myFormat)
addChild(titleText)myFormat.size = 22
var instText:TextField = new TextField()
instText.text = "instructions"
instText.width = titleText.width
instText.x = titleText.x
instText.y = 245
instText.setTextFormat(myFormat)
addChild(instText)inputText.width = 240
inputText.x = 392
inputText.y = 277
inputText.height = 40
inputText.prompt = "Prompt Text"
addChild(inputText)var doneButton:LabelButton = new LabelButton()
doneButton.label = "Done"
doneButton.x = inputText.x
doneButton.y = 330
doneButton.width = 240
doneButton.height = 45
doneButton.addEventListener(MouseEvent.CLICK,exitFunction)
addChild(doneButton)
}override protected function draw():void
{
var g:Graphics = graphics;
g.clear();
g.beginFill(0xCCCCCC,.5);
g.drawRect(0,0,1024,600);
g.endFill();
g.beginFill(0xDDDDDD,1.0);
g.drawRoundRect(262,180,500,270,10);
g.endFill();
}
}
This code was earlier posted on the Developer Forums. It should be noted, that this approach has a slightly different look then the native modal dialogs, and unlike the native dialogs, will not prevent the application from being closed or minimized.