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
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space
Accepted Solution

Return key in TextInput keyboard

[ Edited ]

Hi everyone,

I'm having trouble using the qnx.ui.text.TextInput component. From other threads, I whipped up the following piece of code:

 

			textbox = new TextInput();
			textbox.format.align = "right";
			textbox.text = "1";
			textbox.keyboardType = qnx.ui.text.KeyboardType.PIN;
			//textbox.returnKeyType = "Enter";
			textbox.textField.maxChars = 10;
			textbox.textField.restrict = "0-9";
			textbox.setPosition(10,10);
			textbox.width=236;
			textbox.height = 50;
			textbox.textField.wordWrap = true;
			//textbox.addEventListener(MouseEvent.CLICK, clearTextField);

 which supposely creates a textinput component with right alignment and other stuff.

Now to the problems:

 

1) i am unable to get the text aligned to the right side, the textbox.format.align command does nothing

2) when i click into the textbox, the pin keyboard pops up, which is good. but pressing the ReturnKey, nothing happens. does anyone know how to set an EventListener to it?

 

pyth

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Developer
Posts: 1,269
Registered: ‎12-29-2010
My Device: PlayBook, Z10 LE, Dev Alpha C

Re: Return key in TextInput keyboard

Check out flash.events.KeyboardEvent and links in the AS3 docs there for handling keyboard events:

 

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/KeyboardEvent.html

 

 

Developer
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Return key in TextInput keyboard

uuuh nice, it solves half my problems.thanks for the quick reply, it even works

textbox.addEventListener(KeyboardEvent.KEY_DOWN, printkey);

 

and then checking if its value is 13 for RETURN. do you also know about the align?

 

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Return key in TextInput keyboard

hey pyth,

 

it seems you have to create a new textformat and then apply it to the TextInput object in order to acheive a change in format such as alignment. the below code should change things to the way you want it:

 

 

var myTextFormat:TextFormat = new TextFormat();

myTextFormat.align = TextFormatAlign.RIGHT;
myTextFormat.font = "BBAlpha Sans";
myTextFormat.size = 16;

textbox = new TextInput();
textbox.format = myTextFormat;
textbox.text = "1";
textbox.keyboardType = qnx.ui.text.KeyboardType.PIN;
//textbox.returnKeyType = "Enter";
textbox.textField.maxChars = 10;
textbox.textField.restrict = "0-9";
textbox.setPosition(10,10);
textbox.width=236;
textbox.height = 50;
textbox.textField.wordWrap = true;

 

and as you found out from the previous post, the returnKeyType is an aesthetic change and has not function other than looking like another button. you have to insert the focus out yourself. 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