pixolith / fabricjs-customise-controls-extension

Customise the Icon/Cursor/Action of the fabric.js controls
275 stars 100 forks source link

how to disable delete action when the object is not active. #68

Closed JoeyKo closed 5 years ago

JoeyKo commented 5 years ago

fabric 2.5.0 fabric-customise-controls 2.0.1-beta

Now I can even delete object when it is not selected.

MDSLKTR commented 5 years ago

Hey there, thanks for creating this issue. I'm not sure what your use case is since the object will always be considered active or activated first if you press one of the controls. Is this an issue of stacking multiple objects or do you want to simply disable all controls if something is happening in your code?

JoeyKo commented 5 years ago

@MDSLKTR I wrote a demo in codesandbox. You can try to let the cursor hover on the top-left corner(the object is not active), then click down. https://codesandbox.io/s/k24m95rxn7

I think maybe the es6 import "fabric-customise-controls" causes the problem

MDSLKTR commented 5 years ago

Hey again, yeah i can see what you mean, this probably happening since forever because the object is getting activated by clicking the remove icon which is invisible at that point and then being immediatly removed. Not sure if i can do much about it but i will look into it for sure. Will be keeping you updated.

MDSLKTR commented 5 years ago

Yeah this is an issue that is set somewhere inside the core. As i suspected when the object is not active and you click the corner where remove is set, the event will first trigger the object to become active, which then gets picked up by the remove action checking if this.getActiveObjects() is present and also being triggered by the click propagating through. So afaik there is no way to distinguish this click for me inside the extension.

JoeyKo commented 5 years ago

I'm confused why the live demo page working fine, But import 'fabric-customise-controls' has this problem

MDSLKTR commented 5 years ago

This could be due to the demo running on fabric 1.7 still. I haven't had the time to switch everything to 2 and deprecate 1. I need to confirm this locally first though when upgrading the demo.

MDSLKTR commented 5 years ago

This should be fixed in 2.0.2-beta, thanks @thedarkside