Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone
Accepted Solution

PromptDialog issue (BlackBerry® Tablet OS SDK for Adobe AIR)

I have the following code to display a prompt dialog in which text can be entered after a user clicks a button. The prompt dialog shows 2 buttons: OK and Cancel. Whatever button I click, the program never gets into the event listener function 'onPromptButtonClicked' (I don't see the text "Hello world" in the debugging output).

What am I doing wrong here?

 

private function onBtnAddTextClicked (event:MouseEvent):void {
  var promptSmiley TongueromptDialog = new PromptDialog();
 
  prompt.title = "Title";
  prompt.message = "Please enter text:";
  prompt.addButton("OK");
  prompt.addButton("Cancel");
  prompt.addEventListener(DialogEvent.DIALOG_BUTTON_CLICKED, onPromptButtonClicked);
  prompt.show();
}

private function onPromptButtonClicked(eventSmiley Very HappyialogEvent):void {
 trace("Hello world");
}

Eugene

My PlayBook App: Checklists
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: PromptDialog issue (BlackBerry® Tablet OS SDK for Adobe AIR)

hey eugenevk,

 

yeah unfortunately this is a bug and hopefully gets fixed soon. it was discussed on the forums prior and a work around for it was the following:

 

Replace:

 

 

prompt.addEventListener(DialogEvent.DIALOG_BUTTON_CLICKED, onPromptButtonClicked);

 

 

with:

 

 

prompt.addEventListener(Event.SELECT, onPromptButtonClicked);

 

 

and it should do what you need it to do. here is a thread for reference if you need more information:

 

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/Strange-Dialog-Behaviour/m-p/6681...

 

hope that helps. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone

Re: PromptDialog issue (BlackBerry® Tablet OS SDK for Adobe AIR)

Super, that works. Was breaking my head on it.

Eugene

My PlayBook App: Checklists
Developer
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone

Re: PromptDialog issue (BlackBerry® Tablet OS SDK for Adobe AIR)

JRab, would you also know how to use/access the value of the text entered in the input field of the prompt dialog in de event handler function?

Eugene

My PlayBook App: Checklists
Highlighted
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: PromptDialog issue (BlackBerry® Tablet OS SDK for Adobe AIR)

hey eugenvk,

 

sure thing! you would request the prompt object's text property by doing the following:

 

 

private var prompt:PromptDialog; // placed outside of your main application constructor

(...)

private function onBtnAddTextClicked (event:MouseEvent):void {
	
	prompt = new PromptDialog();
	
	prompt.title = "Title";
	prompt.message = "Please enter text:";
	prompt.addButton("OK");
	prompt.addButton("Cancel");
	prompt.addEventListener(Event.SELECT, onPromptButtonClicked);
	prompt.show();
}

private function onPromptButtonClicked(event:Event):void {
	trace(prompt.text);
}

 

the only thing to remember is to place your prompt dialog object declaration outside of the the constructor in order to have access to it by other functions such as the onPromptClicked(). hope that helps. good luck!

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone

Re: PromptDialog issue (BlackBerry® Tablet OS SDK for Adobe AIR)

Thanks again!

Expected that, but thought there might be another way. I did btw the following, which works as well:

 

prompt.addEventListener(Event.SELECT, function onPromptButtonClicked(event:Event):void{
   var btnOKClicked:Boolean = (event.target.selectedIndex == 0);

   if (btnOKClicked && (prompt.text != "")) {
      trace(prompt.text);
   }
});

Rgrds,

Eugene

Eugene

My PlayBook App: Checklists
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: PromptDialog issue (BlackBerry® Tablet OS SDK for Adobe AIR)

hey eugenevk,

 

you're absolutely right there is another method. if you go back to your old code, you can refer to the text as event.target.text. event.target being your dialog since thats where the event orginated from. sorry for the brain fart hah!

 

 

private function onPromptButtonClicked(event:Event):void
{
	trace(event.target.text);
}

 

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman