FabricJS Catch click on object inside group

后端 未结 7 750
感动是毒
感动是毒 2021-01-17 19:06

I have tried many thing like calculating location, handling with the event we do have in original fabricjs. Does any have done this before?

7条回答
  •  既然无缘
    2021-01-17 19:21

    In FabricJS once the objects have been assembled into a group the Events are only happening there, even the selected events - so you cannot detect which of the items in the group are being selected. Inside the event handler

    var g = new fabric.Group([ rect, text ], {
    g.on('mousedown', function(e) {
        // Inspect, for a collection of the objects in this group
        this._objects
    });
    

    Even attaching event handlers to the objects before assembly into the group the handlers don't fire :(

提交回复
热议问题