FabricJS double click on objects

前端 未结 6 521
孤街浪徒
孤街浪徒 2021-01-02 08:04

I am trying to perform a special action whenever the user double clicks any object located inside the canvas. I have read the docs and not found any mouse:dblclick

6条回答
  •  天涯浪人
    2021-01-02 08:33

    Here is a quick and easy way to add a double click event handler to Fabric JS -

    Include following code snippet to your html file. Just ensure this is loaded after the main fabric.js library

    
    

    Then add this code to listen a double click event:

    canvas.dblclick(function(e) { 
    
    }); 
    

    To get information about the actual object that is being clicked on the canvas, use following method -

    canvas.getActiveObject();
    

    eg.

    canvas.dblclick(function(e) { 
         activeObject = canvas.getActiveObject();
    }); 
    

提交回复
热议问题