Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intended way to update text #32

Closed
aferriss opened this issue May 23, 2018 · 2 comments
Closed

Intended way to update text #32

aferriss opened this issue May 23, 2018 · 2 comments

Comments

@aferriss
Copy link

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?

@bradley
Copy link
Owner

bradley commented May 24, 2018

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;
}

@bradley bradley closed this as completed May 24, 2018
@aferriss
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants