Random cursor position when hitting spacebar
in
Programming Questions
•
1 year ago
Hi All,
I'm very new to processing, but I want t make a type input where you can type words and every time you hit the spacebar the next word should appear somewhere else (random) in the input field.
This is the code I have so far, but I still didn't find out how to make the cursor move to a random position when I hit the spacebar. Any help is appreciated, thanks in advance.
Roos
- String str2 = new String("");
- String tekst = "";
- PFont font;
- void setup() {
- size(400, 400);
- font = createFont("Helvetica", 18);
- }
- void draw() {
- background(255);
- fill(255, 0, 0);
- textFont(font, 18);
- text(tekst+("_"), 35, 95);
- }
- void keyReleased() {
- if (key != CODED) {
- switch(key) {
- case BACKSPACE:
- tekst = tekst.substring(0, max(0, tekst.length()-1));
- break;
- case TAB:
- tekst += " ";
- break;
- case ENTER:
- case RETURN:
- tekst += "\n";
- break;
- case ESC:
- case DELETE:
- break;
- default:
- tekst += key;
- }
- }
- }
1