Advanced Text Box

Get help using Construct 2

Post » Thu Feb 20, 2014 11:58 am

Hi everybody

Due to the demands of a client, we're trying to develop an advanced textbox like this one:

https://www.dropbox.com/s/yoabmqa4j09chr0/image.jpg

Here is the project:

https://www.dropbox.com/s/lg7tme4qulsiztb/AdvancedTextBox.capx

Our first doubt is obvious: How to reach the desired behaviour of this TextBox? Why it don't stop when typing more than two digits?
B
17
S
4
G
1
Posts: 105
Reputation: 1,874

Post » Thu Feb 20, 2014 1:01 pm

Last edited by RamPackWobble on Thu Feb 20, 2014 1:24 pm, edited 1 time in total.
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Thu Feb 20, 2014 1:10 pm

If the events you showed didn't work, this means one thing : the event "on text change" isn't triggered by adding text into the textbox.
Let's take a step back here. Text box are native html form elements and thus dispatch specific events to the system. onTextChanged is triggered when the focus is moved from the box.
So there is another solution : what if you didn't use the native textbox, but instead a 9patch (for the background of the box) and a text element. On click on the "falseBox", you would set it "active", meaning a cursor would start to blink in the text element (every 0.5s, add or remove a | from the text). If the box is active, you would also check for keyboard inputs, compare them to a list of authorized characters, check if the box isn't already full (max length), and finaly add the character if everything is good.

The last trick I have here can help limit the number of character but not the authorized list : at the start of the layout, you could execute some JS to add an html attribute "maxlength" to the text box. This will natively prevent user from inputing more than X character
B
17
S
8
G
4
Posts: 461
Reputation: 6,127

Post » Thu Feb 20, 2014 1:27 pm

RamPackWobble wrote:https://dl.dropboxusercontent.com/u/143636437/examples%20for%20web/temp/advanced%20test%20entry%20box/index.html

Any good to you ?



Wow! That's exactly what I've been trying for weeks!

Damn! How did you designed that?

I'm going to check out the code...
B
17
S
4
G
1
Posts: 105
Reputation: 1,874


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest