Random Text Generator (using stored text/data)

please format your code posting by pasting it into the

</> code button

of the editor header menu ( context name: Preformatted text )
it looks like
```
type or paste code here
```

also can use the ``` manually above and below your code.

thank you.


now we need you to REPAIR your above CODE POSTING,
not make a new / better post.
( just think about the hundred people opening your topic in the future )


a new project just to test some keyboard input
aggregated to ONE string
and show that string

  • on console
  • on canvas

in minimal form


but if you not want try / learn that you still can use a good library

G4P created by Peter Lager

import g4p_controls.*;
GTextField txa;

String userinput="";

public void setup_textarea() {
  G4P.setInputFont("Times New Roman", G4P.PLAIN, 14); // New for G4P V4.3
  G4P.setGlobalColorScheme(GCScheme.PURPLE_SCHEME);
  txa = new GTextField(this, 10, 10, 200, 20);
  txa.tag = "txa";
  txa.setPromptText("Text area ");
  //txa.setText("test", 300);
}

public void show_userinput() {
  fill(0); //________________________ for result text userinput
  text(userinput, 20, height-20); //_ show ( default empty )
}

public void setup() {
  size(300, 300);
  setup_textarea();
}

public void draw() {
  background(200, 200, 0);
  show_userinput();
}

public void handleTextEvents(GEditableTextControl name, GEvent event) { 
    if ( name == txa  && event == GEvent.ENTERED ) {
      userinput = trim( txa.getText() );
      txa.setFocus(false);
      //txa.setText("over write new?");
      txa.setText("");
      txa.setPromptText("next value");
    }
}

// with current G4P V4.3.1
// there is a WARNING
// ####  Unable to create data logger  ####
// please ignore that

1 Like