admin管理员组文章数量:1022989
i create a canvas, i add a fabric Itext, i want to fill text of textbox in Itext. my html code is...
<input type="text" id="title" placeholder="Your Title" /><br>
<canvas id="c"></canvas>
and javascript...
function Addtext() {
var text = new fabric.IText('Enter text here...', {fontSize:16,left:20,top:20,radius:10});
borderRadius = "25px";
canvas.add(text).setActiveObject(text);
text.hasRotatingPoint = true;
}
document.getElementById('title').addEventListener('keyup', function () {
var stringTitle = document.getElementById('title').value;
});
please help...thanks in advance.
i create a canvas, i add a fabric Itext, i want to fill text of textbox in Itext. my html code is...
<input type="text" id="title" placeholder="Your Title" /><br>
<canvas id="c"></canvas>
and javascript...
function Addtext() {
var text = new fabric.IText('Enter text here...', {fontSize:16,left:20,top:20,radius:10});
borderRadius = "25px";
canvas.add(text).setActiveObject(text);
text.hasRotatingPoint = true;
}
document.getElementById('title').addEventListener('keyup', function () {
var stringTitle = document.getElementById('title').value;
});
please help...thanks in advance.
Share Improve this question asked Sep 30, 2016 at 13:49 Kishor AdmaneKishor Admane 691 silver badge11 bronze badges1 Answer
Reset to default 4Your question is very vague. this seems to be something close to what you are asking for. As you type in the textbox the iText updates. Although you can just click in to the iText on the canvas and type right in to so I'm not sure if you really need the html input at all.
window.canvas = new fabric.Canvas('c');
var textOptions = {
fontSize:16,
left:20,
top:20,
radius:10,
borderRadius: '25px',
hasRotatingPoint: true
};
var textObject = new fabric.IText('Enter text here...', textOptions);
canvas.add(textObject).setActiveObject(textObject);
canvas.renderAll()
document.getElementById('title').addEventListener('keyup', function () {
textObject.text = document.getElementById('title').value;
canvas.renderAll();
});
canvas { border: 1px solid; }
<script src="https://cdnjs.cloudflare./ajax/libs/fabric.js/1.6.4/fabric.min.js" ></script>
<input type="text" id="title" placeholder="Your Title" /><br>
<canvas id="c"></canvas>
i create a canvas, i add a fabric Itext, i want to fill text of textbox in Itext. my html code is...
<input type="text" id="title" placeholder="Your Title" /><br>
<canvas id="c"></canvas>
and javascript...
function Addtext() {
var text = new fabric.IText('Enter text here...', {fontSize:16,left:20,top:20,radius:10});
borderRadius = "25px";
canvas.add(text).setActiveObject(text);
text.hasRotatingPoint = true;
}
document.getElementById('title').addEventListener('keyup', function () {
var stringTitle = document.getElementById('title').value;
});
please help...thanks in advance.
i create a canvas, i add a fabric Itext, i want to fill text of textbox in Itext. my html code is...
<input type="text" id="title" placeholder="Your Title" /><br>
<canvas id="c"></canvas>
and javascript...
function Addtext() {
var text = new fabric.IText('Enter text here...', {fontSize:16,left:20,top:20,radius:10});
borderRadius = "25px";
canvas.add(text).setActiveObject(text);
text.hasRotatingPoint = true;
}
document.getElementById('title').addEventListener('keyup', function () {
var stringTitle = document.getElementById('title').value;
});
please help...thanks in advance.
Share Improve this question asked Sep 30, 2016 at 13:49 Kishor AdmaneKishor Admane 691 silver badge11 bronze badges1 Answer
Reset to default 4Your question is very vague. this seems to be something close to what you are asking for. As you type in the textbox the iText updates. Although you can just click in to the iText on the canvas and type right in to so I'm not sure if you really need the html input at all.
window.canvas = new fabric.Canvas('c');
var textOptions = {
fontSize:16,
left:20,
top:20,
radius:10,
borderRadius: '25px',
hasRotatingPoint: true
};
var textObject = new fabric.IText('Enter text here...', textOptions);
canvas.add(textObject).setActiveObject(textObject);
canvas.renderAll()
document.getElementById('title').addEventListener('keyup', function () {
textObject.text = document.getElementById('title').value;
canvas.renderAll();
});
canvas { border: 1px solid; }
<script src="https://cdnjs.cloudflare./ajax/libs/fabric.js/1.6.4/fabric.min.js" ></script>
<input type="text" id="title" placeholder="Your Title" /><br>
<canvas id="c"></canvas>
本文标签: javascripthow to set a textbox text dynamically in fabric js ItextStack Overflow
版权声明:本文标题:javascript - how to set a textbox text dynamically in fabric js Itext - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745476980a2152365.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论