Word Wrapping and TextField help

58 views
Skip to first unread message

Darius

unread,
May 20, 2014, 5:00:03 PM5/20/14
to codenameone...@googlegroups.com
I have set up my TextField in the .res simulator to align the words typed in to the top left corner of the box, but when I tap the box to write in it, the cursor appears in the center left of the box. Is there a way to force it to start, and stay with the text in the top left? Also is there a way to get to words to wrap like in Microsoft Word within the TextField instead of disappearing off the screen?

Shai Almog

unread,
May 21, 2014, 1:31:03 AM5/21/14
to codenameone...@googlegroups.com, briann...@gmail.com
Invoke setSingleLineTextArea(false) on the text field to make it wrap.
Alignment will be tricky, I'm assuming you used padding/margin to tune this but since the native input varies so much between devices getting this to perfectly align in all devices is impossible.

Darius

unread,
May 21, 2014, 1:57:59 AM5/21/14
to codenameone...@googlegroups.com
that seemed to help. when I run the simulator, I click to enter the textfield and the cursor shifts down to the center and the word wrap is off, even though I invoked it in the StateMachineBase under the action event,  but when I click out of the text field, it puts the words in the top left and word wraps them like I want. when I click back in to continue to type, it works like it should. is there a way to make it think I have clicked in and then clicked out so that it positions it correctly right away?

Shai Almog

unread,
May 21, 2014, 12:50:37 PM5/21/14
to codenameone...@googlegroups.com, murdyindustri...@gmail.com
Did you try this on the devices?
Notice the behavior differs between devices so you should test this on devices if its important to you.

Can you provide some screenshots to visualize issue?

murdyindustri...@gmail.com

unread,
May 21, 2014, 1:42:00 PM5/21/14
to codenameone...@googlegroups.com, murdyindustri...@gmail.com

I would like it to do the second photo when I first click into the TextField.

Shai Almog

unread,
May 21, 2014, 11:24:40 PM5/21/14
to codenameone...@googlegroups.com, murdyindustri...@gmail.com
I think that's a limitation of the text field in the simulator that isn't the case with the device.
You can try using TextArea instead of text field since its configured for multiline usage by default.
Reply all
Reply to author
Forward
0 new messages