当前位置:网站首页>Fabric. JS activation input box
Fabric. JS activation input box
2022-07-02 05:18:00 【Director of Moral Education Department】
Brief introduction
give the thumbs-up + Focus on + Collection = Learned to
<br>
stay HTML in ,input The input box has 2 Methods of auto focusing , The simplest is in input Add on label autofocus attribute .
The way to click again is to use JS Get input box element , Call again focus Event check input box .
stay Fabric.js in ,IText Components provide a similar approach .
<br>
<br>
Practice
Fabric.js Of IText Is an editable text box , You can enter text while the project is running , The function is actually the same as HTML Of input almost , Can let the user input .
<br>
By default
stay Fabric.js in , If you're creating IText No text was added to the , It's hard to see where your input box is on the canvas with the naked eye .

<canvas id="canvasBox" width="600" height="600" style="border: 1px solid #ccc;"></canvas><!-- introduce Fabric.js --><script src="https://cdn.bootcdn.net/ajax/libs/fabric.js/521/fabric.js"></script><script> const canvas = new fabric.Canvas('canvasBox') const iText = new fabric.IText('', { left: 100, // The distance from the input box to the left of the canvas top: 100, // The distance from the input box to the top of the canvas padding: 7 // Set the inside margin of the input box }) canvas.add(iText) // Add an input box to the canvas </script>The canvas and input box are created , But it's hard to find the input box with the naked eye .
<br>
Activate the input box
To solve these problems , Input box can be activated .

// Omitted code iText.enterEditing() use enterEditing() Method to activate the input field . At this point, you can see that the position of the cursor is flashing .
<br>
Further
Use enterEditing() The rear input box is activated , You can also see the cursor flashing .
But is that the end of it ?
We can go further , coordination Fabric Canvas Of setActiveObject() Method , Activate the selected object .
In this way, the effect of selecting the input box will be more obvious .

// Omitted code canvas.add(iText).setActiveObject(iText)iText.enterEditing() It can be seen from the above figure that , add setActiveObject() after , The effect is more obvious .
<br>
<br>
summary
Fabric.js It's not hard , It is better than using native Canvas It's a lot easier .
Use Fabric.js The most important thing is to read more documents , Then put multiple api Use in combination , Can create a variety of effects ~
<br>
<br>
Code warehouse
<br>
<br>
Recommended reading
《Fabric.js Output reduced JSON》
《Fabric.js IText Set the specified character color and background color 》
《console.log You can also use illustrations !!!》
《 The front-end needs free online api Interface 》
give the thumbs-up + Focus on + Collection = Learned to
边栏推荐
- Gee series: unit 6 building various remote sensing indexes in Google Earth engine
- Mysql基础---查询(1天学会mysql基础)
- Nodejs (03) -- custom module
- No logic is executed after the El form is validated successfully
- Collectors.groupingBy 排序
- Ansible installation and use
- Implementation of leetcode two number addition go
- Fabric.js 3个api设置画布宽高
- Fabric.js IText 手动设置斜体
- 国产全中文-自动化测试软件Apifox
猜你喜欢

Gee: remote sensing image composite and mosaic
![[common error] the DDR type of FPGA device is selected incorrectly](/img/f3/be66bcfafeed581add6d48654dfe34.jpg)
[common error] the DDR type of FPGA device is selected incorrectly

Super detailed pycharm tutorial

Latest: the list of universities and disciplines for the second round of "double first-class" construction was announced

Mysql基础---查询(1天学会mysql基础)

How to configure PostgreSQL 12.9 to allow remote connections
![Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]](/img/1e/cf0aa09c2fce2278386f12eae4a6cd.jpg)
Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]

Express logistics quick query method, set the unsigned doc No. to refresh and query automatically

Dark horse notes -- Set Series Collection

Pyechats 1.19 generate a web version of Baidu map
随机推荐
Gee series: unit 9 generate sampling data in GEE [random sampling]
Creation and destruction of function stack frames
Global and Chinese market of pressure gauges 2022-2028: Research Report on technology, participants, trends, market size and share
Summary of database problems
LeetCode 241. 为运算表达式设计优先级(分治/记忆化递归/动态规划)
Video cover image setting, put cover images into multiple videos in the simplest way
National all Chinese Automatic Test Software apifox
The underlying principle of go map (storage and capacity expansion)
7.TCP的十一种状态集
Leetcode basic programming: array
There are duplicate elements in leetcode. Go implementation
Gee series: Unit 4 data import and export in Google Earth engine
Thread pool batch processing data
设置滚动条默认样式 谷歌浏览器
Gee series: unit 8 time series analysis in Google Earth engine [time series]
Database batch insert data
Draw a wave chart_ Digital IC
Fabric.js 更换图片的3种方法(包括更换分组内的图片,以及存在缓存的情况)
Ubuntu 20.04 installing mysql8
Gee series: Unit 3 raster remote sensing image band characteristics and rendering visualization