12-21-2010 12:04 PM
Has anyone figured out a way to place a textbox in a dialog extended from qnx.dialog.BaseDialog ? There is a LoginDialog that does this, but for my purposes it should be easier to extend the class, and work up a custom dialog.
Thanks for any suggestions.
12-21-2010 12:12 PM
You cannot currently extend the dialog classes. The classes are merely interfaces to a background service on the PB. This is also the reason they only work on the PB and not in AIR applications. It was mentioned in a webinar that extending and living in application space will be possible in the future. If you need it now, you will probably need to mimic the look and roll your own. I would mimic the API too since when the SDK does support in-app dialogs, then it will be easy to replace.
12-21-2010 12:45 PM
Well that is disapointing.
Extending BaseDialog compiled fine, but I see now that it will not actually run.
As a follow up then, what exactally would be the best way to do this by hand? My first thought is a full screen UIComponent with a significant amount of transparent area on the borders, and some text fields, text labels, and buttons in the middle area. Is this the right approach or is there a better way to do this?
12-21-2010 12:55 PM
hey ebscer,
i would imagine the best way to go is create another sprite class that takes up the entire screen which disables mouse clicks into the program. and in that sprite create another sprite that would hold all the input text boxes and even a grapical background that mimc's a dialog box. and once a user hits enter you can "submit" the data and get rid of the overlay sprite and the "dialog" box. if you can get a class set up to do this dynamically you can potentially do away with QNX dialog boxes and just use your own. good luck!
12-22-2010 11:47 AM
Probably not the best way to do this, but it more or less works, so I figured I would add the approach I eventually used here.
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.LabelButton
public class InputDialog extends UIComponent
{
public var inputText:TextInput = new TextInput();
public function InputDialog(main:MainApp)
{
width = 1024
height = 600
var 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,main. functionName)
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();
}
}
Inside MainApp.functionName you can then call dialog.inputText.text in order to read the entered value.
One other difference is that unlike the built in BaseDialog class it is still possible to minimize or close this application.
12-22-2010 11:52 AM
that looks good ebscer
gets the job done too! thanks for the update
12-23-2010 04:12 PM
Ebscer wrote:
... One other difference is that unlike the built in BaseDialog class it is still possible to minimize or close this application.
Note that if you do the following, the standard dialogs will not be modal either, so you can minimize or close the app just fine:
import qnx.display.IowWindow; ... var alert = new SomeDialogBaseOnBaseDialog(); ... alert.show(IowWindow.getAirWindow().group);
12-28-2010 02:54 PM
I'm a newbe with actionscript. Could you post some code to show how to use InputDialog? I keep getting errors.
Thank You
12-28-2010 03:16 PM
If you're getting errors as an AIR application, it is because the dialog system is a service that runs on the PB that is not available outside the simulator. If you're getting other errors, please post what errors you are getting so we can assist you better.
12-28-2010 03:57 PM
I'm not using the dialog system. I'm trying to use the InputDialog class that Ebscer posted. I'm getting a "1178: Attempted access of inaccessible property functionName through a reference with static type myApp." error. Here's the code I'm using.
var myApp:MyApp = new MyApp();
inputDialog = new InputDialog(myApp);
addChild(inputDialog);
private function functionName():void
{
removeChild(inputDialog);
}
Thanks