Alex Rivera | Logout

Interactive text fields with Fabric.js

Asked 2012-04-04T10:11:33.017
34

I've been playing with Fabric.js a lot in the last few weeks, but regarding text fields I've only found it possible to set the text on creation.

Is there any possible way to make an interactive text field, or do I have to find a workaround to achieve that? (With interactive text field I mean an area of the canvas I can click on and write directly into it.)

Edit
Report

2 Answers

4
    text.set({ text: newText }); //Change the text
    canvas.renderAll(); //Update the canvas

That was what I was looking for :) Thanks alot!

answered 2013-03-12T12:34:11.090
0

assuming you have both the canvas and the context as variables in your script:

// write text
context.fillText("text1",0,0);


// refresh canvas and write new text
context.clearRect(0,0,canvas.width,canvas.height);
context.fillText("text2",0,0);
answered 2012-04-04T15:10:04.140

Your Answer