01-11-2011 09:13 PM
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.
Any ideas folks?
01-11-2011 09:19 PM
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!
01-12-2011 06:22 AM
@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 :-) ).
01-12-2011 07:19 PM
@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.
01-12-2011 07:25 PM
try doing doing "right" instead of "left". also the TextFieldAutoSize class is a flash class thats not a part of the qnx libraries.
it stores a bunch of constants such as left, center, right, etc.
you can find more detail here:
03-18-2011 09:18 PM
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!
03-18-2011 11:12 PM
try tapping right next to the start of the TextInput field. like 10 pixels in and not anywhere else like the middle. good luck!
03-20-2011 02:04 AM
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!
var myTextInput:TextInput = new TextInput(); (... stuff ...) myTextInput.textField.wordWrap = true; (... stuff ...)
hope that helps. good luck!