简体   繁体   中英

Change cursor Color in Fabric.js

I am using the Textbox option of the Fabric.js library.

Is it possible to change the color of the cursor in the textbox . If the textbox is placed on a dark image, I can make the text appear a bit clear by easily changing the font color but its not at all easy to even locate where the cursor is.

Yes this is very much possible. This is what you need:

 var canvas = new fabric.Canvas("c"); var text = new fabric.Textbox('Hellow wordld is a textbox in one line', { width:250, cursorColor :"blue" }); canvas.add(text) 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> <script src="http://fabricjs.com/lib/fabric.js"></script> <canvas id="c" width="400" height="400"></canvas> 

Here is the Fiddle Link. Code wont work here properly. Check the fiddle for the demo. Basically you have to add a property as cursorColor while creating Fabric Textbox and it will do what you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM