We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I'm a beginner, I'm trying to create a simple application with 2 numeric input box. I would like return the sum of these in another box. But I don't know how to create the input box and to take the value in the two respective variables. Would you know how I could do it?
Answers
Let’s say you have setup and draw
You have 2 String variables defined before setup as ““ Make a 3rd function keyPressed
Here say
When Return is presses say
textBox1HasFocus=false;Before setup say
In draw () use rect() and text(str1 ,.....
and text(str2, ....
Then when return is pressed again display the sum....
Hit ctrl-t
Show your entire code here
https://Gist.GitHub.com/GoToLoop/bba0c288aaeeb5ef9bb1
Sorry I didn't understand very well Chrisir.
At moment my code is
int box1X, box1Y, box2X, box2Y; int LargBox, AltezzaBox; float str1, str2; color coloreBox; boolean textBox1HasFocus, textBox2HasFocus; void setup() { size(640, 360); noStroke(); background(200); LargBox=width/5; AltezzaBox=height/10; box1X = 10; box1Y = 10; box2X = box1X + LargBox + 10; box2Y = 10; } void draw() { fill(255); rect(box1X,box1Y,LargBox,AltezzaBox); rect(box2X,box2Y,LargBox,AltezzaBox); } // ---------- Funzioni --------------------- void keyPressed(){ if(textBox1HasFocus){str1=str1+key;} else {str2=str2+key;} }Thanks GotoLoop I would try to learn step by step how to make this thing if it's possible,
I worked a little on your sketh