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 › Odd behavior with ControlP5 Textarea
Page Index Toggle Pages: 1
Odd behavior with ControlP5 Textarea (Read 665 times)
Odd behavior with ControlP5 Textarea
Jul 5th, 2009, 2:43pm
 
Hi everyone. I am very new to Processing and ControlP5, but have been learning a lot.

I am trying to create an app wherein the user can press a key on a midi keyboard and type a name into a text field so that I can bind the note value to a string in an ArrayList. I've got that part working, but am stuck on the text input using ControlP5.

I have been able to create a Textfield, and a corresponding routine, which  sets the text value of the Textarea. the problem is, it doesn't clear the text that was already there. It just turns the Textarea into gibberish by overwriting the previous text. How do I clear the old text?

Can anyone help here?

Code:

import controlP5.*; //Also a GUI library. Which will be easier to use?

public Textarea curNoteName;
public ControlP5 controlP5;

void setup() {
size(400,400);
background(0);

controlP5 = new ControlP5(this);
controlP5.addToggle("learn",false,20,20,20,20).setId(1);
controlP5.addButton("enter",100,50,20,50,20).setId(2);
controlP5.addTextfield("note",110,20,100,20).setId(3);
curNoteName = controlP5.addTextarea("display","Note?",220,20,100,20);

}

void draw() {
controlP5.update();
}


void controlEvent(ControlEvent theEvent) {
println("got a control event from controller with id "+theEvent.controller().id());
if (theEvent.controller().id() == 3) {
println("You Entered a note name");
}
}

void note(String theText) {
curNoteName.setText("");
curNoteName.setText(theText);
}


Re: Odd behavior with ControlP5 Textarea
Reply #1 - Jul 5th, 2009, 3:23pm
 
UPDATE: I was able to fix this behavior by adding a background(0); to the draw() routine.

I'm still very overwhelmed by the ControlP5 library, even as I can see how cool and helpful it is. Unfortunately, I'm both educated and confused by the sample code. Are there more detailed tutorials available?

Page Index Toggle Pages: 1