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: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers

TextInput prompt cut off...bug?

Hey guys,

 

I have a textInput and want the font size to be set to 18.

While I got that working, I noticed that the "prompt" methods output...i.e. the text is cut off a bit.

 

Is that a bug or am I doing something wrong?

 

Here is the code:

 

 

var textFormat:TextFormat = new TextFormat();
			textFormat.size = 18;
			textFormat.align = "right";
			
			// Input text.
			inputText = new TextInput();
			inputText.setSize(250,50);
			inputText.textField.defaultTextFormat = textFormat;
			inputText.prompt = "Input";
			inputText.setPosition(50,100);
			inputText.textField.restrict = "0-9 \.";		// Restrict to only numbers from 0 to 9 AND the decimal.
			inputText.textField.wordWrap = false;
			inputText.textField.maxChars = MAX_INPUT_LENGTH;
			inputText.addEventListener(Event.CHANGE, inputNumberEntered);
			inputText.addEventListener(KeyboardEvent.KEY_UP, EnterEntered);
			addChild(inputText);

 

Here is the image (if you don't see it, wait for the moderators to approve it)...notice how the "p" is cut off.

 

inputquestion.png

 

 

Any ideas folks?

 

 

G

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

Re: TextInput prompt cut off...bug?

hey gpatton,

 

i ran into the same problem before. to workaround it you need to set the autoSize property of the TextInput object like this:

 

 

inputText.autoSize = TextFieldAutoSize.LEFT;

 

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: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: TextInput prompt cut off...bug?

@gpatton, sorry this isn't a solution, just an unrelated minor point. 

 

In your restrict property (which is not a full regular expression, just a String) you have for some reason escaped the period, though this not only isn't required but doesn't actually do anything.

 

Fortunately, including a backslash before a character that doesn't need to be escaped appears to be harmless, as the backslash is simply dropped from the string.

 

Anyway, using just "0-9 ." is sufficient and would be less confusing to another reader (like me, who had to read up on this to be sure :-) ).


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!
Developer
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers

Re: TextInput prompt cut off...bug?

@JRab - When I do the line you told me to add...I get the following error:

 

Error 1120 -  Access of undefined property TextFieldAutoSize.

Anything I need to import other than qnx.ui.text.* ??

 

However, if I do:

inputText.autoSize = "left"

 

then I get no errors but my "Input" prompt gets worse. The "nput" part disappears but the "I" stays there.

 

Weird....any ideas?

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

Re: TextInput prompt cut off...bug?

hey,

 

try doing doing "right" instead of "left". also the TextFieldAutoSize class is a flash class thats not a part of the qnx libraries.

 

 

import flash.text.TextFieldAutoSize;

 

 

it stores a bunch of constants such as left, center, right, etc.

 

you can find more detail here:

 

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextFieldAutoSize.html

 

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
New Contributor
Posts: 2
Registered: ‎03-18-2011
My Device: None
My Carrier: None

Re: TextInput prompt cut off...bug?

Thanks - The TextFieldAutoSize.LEFT property fixes the cutoff issue.  However, setting the autoSize property of my TextInput control to any value of TextFieldAutoSize makes the control unusable in the emulator.  Whenever I have something set for the property, clicking the TextInput control in the emulator doesn't do anything, e.g. I can't actually click it to focus it and enter text.

 

However, when I use the TAB key on my keyboard, it cycles through all of the controls on the screen, at which point I can type into the TextInput control (which is how I know that property fixed the cutting off issue).

 

Is this just a glitch in the emulator, or will a user on a real PlayBook not be able to select the text box?

Any suggestions?  Thanks!

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

Re: TextInput prompt cut off...bug?

hey RyGuy,

 

try tapping right next to the start of the TextInput field. like 10 pixels in and not anywhere else like the middle. 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
New Contributor
Posts: 2
Registered: ‎03-18-2011
My Device: None
My Carrier: None

Re: TextInput prompt cut off...bug?

Thanks!  It works great.  I'm assuming this means it will work fine on an actual device?

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

Re: TextInput prompt cut off...bug?

hey RyGuy,

 

yah hopefully that is the case hah. alternatively, try setting the wordWrap property to true. i've done this in the past and i could click anywhere in the TextInput and focus on nicely. I dont know how it will result now but its worth a shot!

 

Example:

 

 

var myTextInput:TextInput = new TextInput();

(... stuff ...)

myTextInput.textField.wordWrap = true;

(... stuff ...)

 

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