Get value from text Input control

solved
#1

When adding a Input control at a canvas the text property can be set, but this is only some text displayed at the right side of the control.
These text can be accessed with :

canvas.getElement("Input").text; // gets "My Input"

But how to get the text/value from the left side of the control that typed during runtime?
I tried value, but there is no field value

canvas.getElement("Input").value;  // Error: no field value

In the following example I typed 12345 in a control with the name “Input” and the text “My Input”
input

How can I get my typed value back from the control?

1 Like

#2

use:

Std.parseFloat(a) // where a is canvas.getElement("Input").text

Std.parseFloat() parses value from string

0 Likes

#3

I know how to parse a value form string, the problem is that I can’t get the text I typed to the control.

canvas.getElement(“Input”).text gives as result “My Input” and not “12345”.

0 Likes

#4

Have a look at the DebugConsole.hx
https://github.com/armory3d/armory/blob/master/Sources/armory/trait/internal/DebugConsole.hx

There can you see how to insert the control per code and get the input.

1 Like

#5

Oh ok try this:

canvas.getHandle("Input").text;

.getElement() get info about element, in our case it was getting placeholder

2 Likes

#6

Thanks a lot!
That works fine. :slight_smile:

1 Like

#7

Thanks for the hint, the source code from the DebugConsole helps me!

1 Like

#8

Wow…I was trying to make a simple “sum 2 numbers” program. I was almost giving up :-
Thanks this forum I get it working!

0 Likes