How do I keep text vertically in place in text field?

Get help using Construct 2

Post » Tue Jan 03, 2017 1:54 pm

I have a text object that display the email address of my users when they type it on a OnScreen keyboard. I use this technique because the Input Text box get resize very small thanks to the Android' own keyboard. (export HTML5)

So, when the user touch the sprites buttons, I simply update a variable (e.g. myText=myText&"A") then set text to my Email Box to this variable. Everything is fine until there is too many characters.

The Textbox can contain about 30 characters max (I cannot change this for design purpose) and must have fixed width.

When I get to type a very long email (which contain no space) the text completely disappear. If I enlarge the height of the text box I can see what happen, it does really shift like half a line down

Wrapping word or character don't change anything. What I look for is the behavior that text does when you select "SINGLE LINE" in Flash. Meaning the text on the left is just push toward the left as you type so you can still see what you are typing.

Is there a way to fix that? Please ask me if you need more info.
B
14
S
5
G
1
Posts: 25
Reputation: 1,546

Post » Wed Jan 04, 2017 4:35 am

You can simply trim the text in Email Box to 30 characters. It will look like the text is shifting to the left as the user types over 30 characters.

Code: Select all
EmailBox:  Set Text to Right(myText,  30)



Update: I tried it and it appears that the Right(string,30) function works incorrectly when the string is shorter than 30 chars, so you can modify it to something like this:

Code: Select all
EmailBox:  Set Text to Right(myText,  min(len(myText), 30))
or
EmailBox:  Set Text to len(myText)>30 ? Right(myText, 30) : myText
Check out my awesome game Doptrix
B
17
S
9
G
51
Posts: 842
Reputation: 28,493

Post » Wed Jan 04, 2017 7:21 am

Maybe try the anchor behavior?
B
21
S
6
Posts: 59
Reputation: 1,387

Post » Thu Jan 05, 2017 3:29 am

thx a lot DOP2000, it is really appreciated!
B
14
S
5
G
1
Posts: 25
Reputation: 1,546


Return to How do I....?

Who is online

Users browsing this forum: MrSheet and 28 guests