Text Input is giving me problems!

Edition 1.19.3

I’m trying to wrap my mind around the text input object… the ultimate goal is to have a user enter a number value that passes to a variable and can be used in the project code to make other things happen. But at this point, I’m just trying to get the value from the input to appear in another text field when I click a button. I’ve looked at lots of examples, but they all seem so complicated. I feel like I can have a button, when its pressed the value of the textInput passes to a variable and then the text field picks up the variable to show what was input.

I tried to attach my example but “new user”… don’t see why its not working :crazy_face:

Here’s the code I attached to the button within a “mouseclick” script:
project.textVar = project.textInput.value;
project.texter.setText(textVar);

textVar is my variable, textInput is the name of the input text object. Texter is the name of the text field.

Thanks

Could you send the file?
Also I think it all has to be in the same frame

Try this instead:

var textVar = project.textInput.activeFrame._children[0].value;
project.texter.setText(textVar);

No go. How about the simplest example of sending what you put into the input field to a variable… or even output it to console when a button is clicked.

I tried a more basic situation and found a problem. I have two text fields and a button. One text field called “textin” and one called “texter.” There is a random word in each. Then, on a button (mousepressed script) I have the code:
var textVar = textin;
texter.setText(textVar);

I also tried:
var textVar = textin.value;
texter.setText(textVar);

I expect the string that was in “textin” to become the value of the variable textVar… then texter should change to match that string. No go.

Here’s a file that might help:
My Project2-26-2021_19-41-30.wick (4.9 KB)

What I did was edit the textbox’s timeline, and name the box clip in there “box,” then from the project, I referred it to “this.box.value.”

Let me know if this is what you needed

AWESOME! That got me what I was hoping for! New question now…

How do I get Wick to treat numbers in the textInput as a number rather than a string?

I made two textInput box… if you put 2 in one and 3 in the other I get 23 as the result of 2 + 3… since its treating the numbers as strings and concatenating.

Found an answer…

Number();

… converts a string to a number… if it can be converted.

Nice!

A different method that I usually use to turn values into numbers is multiply them by 1
(when multiplying, wick automatically turns the value into a number)

Ex:

alert((variable*1)+5);

You can use whatever method you find easier