We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Control P5 - text use (input)
Page Index Toggle Pages: 1
Control P5 - text use (input) (Read 1472 times)
Control P5 - text use (input)
May 21st, 2009, 3:05am
 
I have been using this library but need to extend it in order for the user to add more text. I am trying to make an application that will use objects with 2D bar codes to trigger an different graphic "enviroments" in which users can type poems or short stories or songs and then saving them into XML - for a self documentatio exhbition in Yeoville Johanesburg.

I'm begining to think that inputing text longer than one line is not possible with processing? How can I extend the text field to take more than one line of text or is there any suggestion for anouther method?

feeling very stuck
thank you
Re: Control P5 - text use (input)
Reply #1 - May 21st, 2009, 6:44am
 
hi tegan -
i too have ran into the problem of wanting an idiomatic text area in processing. controlp5 has a very nice textarea class for displaying multi-line data, but as far as i can see you are correct that controlp5 doesn't handle the mvc problems associated with interactive input into that textarea (cursor, up, down, delete, interactive word wrap). it's certainly not true that it's impossible in processing, though - i'm currently working on something like a console that will be able to do what you say. i suggest you make your own wrapper for the controlp5 class that handles keyboard input and appropriately updates the string through controlp5.textarea.setText( String s ). something like this:

Quote:
import controlP5.*;

ControlP5 controlP5;
Textarea myTextarea;
StringBuilder sb;

void setup() {
  size(400,400);
  frameRate(30);
  controlP5 = new ControlP5(this);
  myTextarea = controlP5.addTextarea(
     "label1",
     "type some text until it fills up the space",
     100,100,200,60);
  myTextarea.setColorForeground(0xffff0000);
  sb = new StringBuilder();
}

void draw() {
  background(0);
  fill(255);  
}

void keyPressed()
{
   sb.append( key );
   myTextarea.setText( sb.toString() );
}



Page Index Toggle Pages: 1