Blobinabottle
Blobinabottle

Reputation: 15

Fabricjs : item locked but group selection possible

Basically I'm trying to reproduce this behavior for locking/unlocking item in fabricjs: https://www.dropbox.com/s/undtb1v4kxqcbi8/ScreenFlow-lock.mp4?dl=0

=> I want to be able to lock an item, but still be able to clic and drag a selection from it, but still being able to select it (but not moving/scaling,etc).

I can lock an item and be able to start a drag selection from it: https://jsfiddle.net/og09g5ex/

var rect = new fabric.Rect({
left: 100,
top: 100,
fill: 'red',
width: 150,
height: 150,
transparentCorners: false,
evented:false,
selectable:false});

But then I can't select it because I use "evented=false".

Does anyone has an idea?

Many thanks!

Upvotes: 1

Views: 1329

Answers (1)

StefanHayden
StefanHayden

Reputation: 3669

This is possible but it is not easy. There is a findTarget in the canvas.class.js file that you will need to modify so that when you are clicking on the object you select it but when you are clicking then dragging it does not select it. naively fabric does not have this concept and modifying this function is the only way to get it. Hope that helps!

Upvotes: 1

Related Questions