Loading...
Logo
Processing Forum
keyboard.zip

This is the part of the code i've been having trouble with... It prints a string but it runs off the left side when it becomes larger. I don't know where I'm going wrong with this.  The cursor can stay between two strings 's' and 's2' which are divided up in an Arraylist full of characters typed. 
Copy code
  1.   if(update){
  2.     if(!textField.isEmpty()){
  3.       for(int i=0; i<cur;i++){
  4.         s+=Character.toString(textField.get(i));
  5.       }
  6.       
  7.       for(int i = cur; i<textField.size();i++){
  8.         s2+=Character.toString(textField.get(i));
  9.       } 
  10.       sw = textWidth(s);
  11.     }
  12.   }
  13.   if(!textField.isEmpty()){text(s,10,50);}
  14.   line(10+sw,0,10+sw,100);
  15.   if(cur!=textField.size()){text(s2,11+sw,50);}
  16.   s="";
  17.   s2="";
I recommend running it to try to code out.

Replies(1)

Did you end up figuring this out?  Your .zip file was empty upon download on my machine, so it was hard to get a context for the code you pasted.