ControlP5 has any copy and paste function in Textarea or input field?

-a- i take that example again
-b- and cut it down to that one text area

/**
 This sketch is to demonstrate some features of GTextArea controls. 
 
 for Processing V2 and V3
 (c) 2015 Peter Lager
 
 */

import g4p_controls.*;

GTextArea txa1;

public void setup() {
  size(500, 300);
  G4P.setGlobalColorScheme(GCScheme.PURPLE_SCHEME);
  txa1 = new GTextArea(this, 10, 10, 480, 280);
  txa1.tag = "txa1";
  txa1.setPromptText("Text area 1");

}

public void draw() {
  background(200, 128, 200);
}

public void displayEvent(String name, GEvent event) {
  String extra = " event fired at " + millis() / 1000.0 + "s";
  print(name + "   ");
  switch(event) {
  case CHANGED:
    println("CHANGED " + extra);
    break;
  case SELECTION_CHANGED:
    println("SELECTION_CHANGED " + extra);
    break;
  case LOST_FOCUS:
    println("LOST_FOCUS " + extra);
    break;
  case GETS_FOCUS:
    println("GETS_FOCUS " + extra);
    break;
  case ENTERED:
    println("ENTERED " + extra);  
    break;
  default:
    println("UNKNOWN " + extra);
  }
}

public void handleTextEvents(GEditableTextControl textControl, GEvent event) { 
  displayEvent(textControl.tag, event);
}

-c- test the cut and paste

-d- @quark
why i can not have a empty line by [enter]

-e- so, now i want understand your question?
what you want to do?
save the content of the edited text area to a file?
( basic feature of a text editor )

or add some more text from any string into the text area
++ at the end?
++ at cursor position? ( that one might be tricky )

2 Likes