bradley/Blotter

Intended way to update text

aferriss opened this issue · 2 comments

Hey there! I'm trying to figure out how to change the text rendered on screen in a more dynamic way. Your documentation mentions a couple times that you simply just call blotter.needsUpdate = true, but it never provides an example of how to do so.

Essentially what I'm after is an interface with a text input box. When the user hits enter on the box, the text will be sent to blotter to render. The only way I've been able to do it so far, is to keep appending new scopes to the screen. I feel like I'm missing something, or is this how you intended things to work? Here's a little example written the p5js editor. Every click will add a new scope to the window. I know that I could keep track of the old scopes and remove them as I get new submissions, but I feel like there has to be a way to tell blotter to just redraw the text texture.

Can you give some clarity or guidance on how to do this kind of update?

To update the text value of a Blotter.Text already rendered in Blotter, you simply need to set the value property on the text object and then set needsUpdate to true on either to Blotter instance or the Blotter.Text instance.

In you example, change the update function to this:


function mousePressed() {

  txt.value = "two";
	
  txt.needsUpdate = true;
}

Perfect, thanks @bradley . I wonder if it's worth updating your docs with a note about how to do this?