# Make text that is drawn, editable

**URL:** <https://discourse.processing.org/t/make-text-that-is-drawn-editable/15091>\
**Category:** Libraries\
**Created:** [October 31, 2019, 9:16pm UTC](https://discourse.processing.org/t/make-text-that-is-drawn-editable/15091 "2019-10-31T21:16:29Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [November 1, 2019, 3:24am UTC](https://discourse.processing.org/t/make-text-that-is-drawn-editable/15091/4 "2019-11-01T03:24:04Z")

</div>

please repair all your code posting  
use:

```auto
</> button from forum editor

```

looks like  
```  
type or paste code here  
```

* * *

why you make the  
cp5 declaration inside draw? instead setup?

for what still have a text(); inside draw?

where is your event code??

not sure you wanted to do this?

```auto
/* ControlP5 by Andreas Schlegel, 2012 www.sojamo.de/libraries/controlp5 */

import controlP5.*;
ControlP5 cp5;
Textfield tf;
ColorWheel cw;

String textValue = "#123456";
String hexc = "";
color c_cw; // ____________________________________________ from color wheel
int r_cw, g_cw, b_cw;
int r_tf, g_tf, b_tf; // __________________________________ from textfield FFFFFF

boolean diagp = true;

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

  cp5 = new ControlP5(this);

  tf = cp5.addTextfield("input")
    .setPosition(20, 100)
    .setSize(100, 20)
    .setValue(textValue)
    .setFocus(true)
    .setAutoClear(false)
    .setColor(color(255))
    ;

  cw = cp5.addColorWheel("cw", 20, 80, 220 )
    .setRGB(color(128, 0, 255))
    .setPosition(150, 100)
    ;

}

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

public void cw(color c) { // _______________________________________ event code cw
  if ( diagp ) print("event cw color "+c+" "); // _________________________________ set some globals
  r_cw = (int)red(c);
  g_cw = (int)green(c);
  b_cw = (int)blue(c);
  if ( diagp ) println(r_cw,g_cw,b_cw);
  c_cw = c;
  hexc = hex(c, 6);
  tf.setValue(hexc); // ____________________________________________ set textfield
}

public void input(String theText) { // event__ automatically receives at ENTER results from controller input
  if ( diagp ) print("event input text : "+theText+" ");
  String rs = theText.substring(0,2);
  r_tf = hex2decimal(rs);
  String gs = theText.substring(2,4);
  g_tf = hex2decimal(gs);
  String bs = theText.substring(4,6);
  b_tf = hex2decimal(bs);
  if ( diagp ) println(r_tf,g_tf,b_tf);
  cw.setRGB(color(r_tf,g_tf,b_tf));
}

public int hex2decimal(String s) {
  String digits = "0123456789ABCDEF";
  s = s.toUpperCase();
  int val = 0;
  for (int i = 0; i < s.length(); i++) {
    char c = s.charAt(i);
    int d = digits.indexOf(c);
    val = 16*val + d;
  }
  return val;
}

```

---

_[View the full topic](https://discourse.processing.org/t/make-text-that-is-drawn-editable/15091)._
