02-22-2012 03:55 PM - last edited on 02-22-2012 03:58 PM
Hello,
a short question from my side. I have created my own helper packe:
package helpers
{
import qnx.dialog.PromptDialog;
public class MyDialog extends PromptDialog
{
public var dialogId:int = 0;
public function MyDialog()
{
super();
}
}
}
Then in my App I do:
package
{
...
import helpers.*;
...
public class Testproject extends Sprite
{
private var testDialog:MyDialog;
testDialog = new MyDialog();
testDialog.message = "Please enter text";
testDialog.prompt = "[Textinput]";
testDialog.dialogId = 1;
testDialog.addButton("OK");
testDialog.setButtonPropertyAt(DialogButtonPropert y.CONTEXT, "enterText", 0);
testDialog.addButton("Cancel");
testDialog.setButtonPropertyAt(DialogButtonPropert y.CONTEXT, "cancel", 1);
testDialog.addEventListener(Event.SELECT, onDialogButton);
testDialog.show(IowWindow.getAirWindow().group);
}It compiles without any errors, but does not work. I do not receive any input prompt/popup on the tablet.
If I do it with the normal PromptDialog() class instead of my MyDialog class from the helper package, then everything works fine. Any ideas? I am not that experienced in object oriented programming languages and believe that I do something terribly wrong here...
02-22-2012 04:13 PM
Hey,
From what I remember the Dialog classes in the QNX library arent really classes -- they are a service in the playbook (PPS). So you can't extend them and create a custom class. They can only be called and used as is. Hope that clears things up. Good luck!
02-22-2012 05:01 PM - last edited on 02-22-2012 05:05 PM
Hello,
thank you for the quick reply. Good to know. Then I will have to find another way around for my problem.
Let me explain what I am trying to do:
Basically I want to generate a sequence of input dialogs in order to gather all the necessary data from the user before my app actually starts off. So after clicking on my start button:
var startBtn:LabelButton = new LabelButton(); startBtn.label = "Play"; startBtn.x = stage.stageWidth / 2 - startBtn.width / 2; startBtn.y = 420; startBtn.addEventListener(MouseEvent.CLICK, resetData); addChild(startBtn);
I trigger the first Input dialog:
private function resetData(event:MouseEvent): void
{
inputDialog(1);
}
Then I call my function which contains all my dialogs:
private function inputDialog(DialogID:int):void
{
switch(DialogID)
{
//read asset amount
case 1:
testDialog = new PromptDialog();
testDialog.message = "How many?";
testDialog.prompt = "[amount]";
testDialog.id = "1";
// add buttons and associate semantic context tags to them
testDialog.addButton("OK");
testDialog.setButtonPropertyAt(DialogButtonPropert y.CONTEXT, "enterText", 0);
testDialog.addButton("Cancel");
testDialog.setButtonPropertyAt(DialogButtonPropert y.CONTEXT, "cancel", 1);
break;
//read information for each asset
case 2:
testDialog = new PromptDialog();
testDialog.message = "Value please";
testDialog.prompt = "[value]";
testDialog.id = "2";
// add buttons and associate semantic context tags to them
testDialog.addButton("OK");
testDialog.setButtonPropertyAt(DialogButtonPropert y.CONTEXT, "enterText", 0);
testDialog.addButton("Cancel");
testDialog.setButtonPropertyAt(DialogButtonPropert y.CONTEXT, "cancel", 1);
break;
//case 3 not implemented yet
default:
break;
}
testDialog.addEventListener(Event.SELECT, onDialogButton);
testDialog.show(IowWindow.getAirWindow().group);
}
And then I catch the events from the input screen to proceed the data:
private function onDialogButton(event:Event):void
{
switch (testDialog.id)
{
case "1":
/* Respond to the user's input. */
if ("enterText" == testDialog.getButtonPropertyAt(DialogButtonPropert y.CONTEXT, testDialog.selectedIndex))
{
//amount
amount=int(testDialog.text);
InputCount=0;
inputDialog(2); //dialog finished, call the next dialog
}
else
{
this.clearScreen();
this.drawWelcomeScreen();
}
break;
case "2":
if ("enterText" == testDialog.getButtonPropertyAt(DialogButtonPropert y.CONTEXT, testDialog.selectedIndex))
{
//set values
ListEntries[InputCount]=testDialog.text;
InputCount++;
//check if each entry has its value set
if(InputCount<amount) {
inputDialog(2); //if no, ask again
}
else {
inputDialog(3); //if yes, proceed to next dialog
}
}
else
{
this.clearScreen();
this.drawWelcomeScreen();
}
//case 3 not implemented yet
break;
}
}This did not work properly, as soon as I call the inputDialog(2) from within the switch-case statement, the thing gets messed up and no further dialog appears. So I wondered if it might be somthing with the testDialog.id I am using and that is why I wanted to create my own helper class containing an int ID which I can use for that.
I am pretty sure that there is a more efficient and structured way to implementing a long sequence of input dialogs with logic in it, but my programming skills are limited and I am trying to learn ![]()
I guess it is a bad idea to call the inputDialog() from within the onDialogButton() function, but I am not sure how to implement it better.
Any help would be appreciated!!
02-23-2012 12:50 PM