使用Fabric.js的交互式文本字段 [英] Interactive text fields with Fabric.js

查看:1418
本文介绍了使用Fabric.js的交互式文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在过去几个星期里一直在使用Fabric.js,但是对于文本字段,我只能在创建时设置文本。

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.)

推荐答案

fabric.js版本包括一个类IText,它集合了用于动态编辑和选择文本的交互。尝试下面的代码用最新版本的fabric.js

The latest version of fabric.js includes a class IText which incorporates the interaction for editing and selection of text dynamically. try the code below with the latest version of fabric.js

canvas.add(new fabric.IText('Tap and Type', { 
  fontFamily: 'arial black',
  left: 100, 
  top: 100 ,
}));

这篇关于使用Fabric.js的交互式文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆