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

Reply
Developer
Ebscer
Posts: 817
Registered: ‎08-31-2009
My Carrier: Verizon

Text input in modal dialog

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.


Read my thoughts on BlackBerry Development at news.ebscer.com
Please use plain text.
Developer
jtegen
Posts: 6,535
Registered: ‎10-27-2010
My Carrier: Verizon

Re: Text input in modal dialog

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.

Please use plain text.
Developer
Ebscer
Posts: 817
Registered: ‎08-31-2009
My Carrier: Verizon

Re: Text input in modal dialog

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?


Read my thoughts on BlackBerry Development at news.ebscer.com
Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010

Re: Text input in modal dialog

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!

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
Please use plain text.
Developer
Ebscer
Posts: 817
Registered: ‎08-31-2009
My Carrier: Verizon

Re: Text input in modal dialog

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.


Read my thoughts on BlackBerry Development at news.ebscer.com
Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010

Re: Text input in modal dialog

that looks good ebscer :smileyhappy: gets the job done too! thanks for the update

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
Please use plain text.
Developer
peter9477
Posts: 6,447
Registered: ‎12-08-2010
My Carrier: none

Re: Text input in modal dialog

 


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);

 

 

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Trusted Contributor
PBDev
Posts: 108
Registered: ‎12-28-2010
My Carrier: Verizon

Re: Text input in modal dialog

I'm a newbe with actionscript. Could you post some code to show how to use InputDialog? I keep getting errors.

 

Thank You

Please use plain text.
Developer
jtegen
Posts: 6,535
Registered: ‎10-27-2010
My Carrier: Verizon

Re: Text input in modal dialog

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.

Please use plain text.
Trusted Contributor
PBDev
Posts: 108
Registered: ‎12-28-2010
My Carrier: Verizon

Re: Text input in modal dialog

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

Please use plain text.