SoftwareBrothers/fabricjs-viewport

Shift + Click does not select multiple objects

sameerxanand opened this issue · 1 comments

When you hold shift and click multiple objects in edit mode, it should be selecting all of those objects. You can see this works with the demos on FabricJS's main homepage. However, this is not working with fabricjs-viewport.

Hi,

You can work around this by altering the following method, to ensure that it passes on the shiftKey parameter in the event that is returned:

Viewport.prototype._transformEventParams = function (e) {
            var offsetLeft, offsetTop;
            offsetTop = this.canvas.wrapperEl.getBoundingClientRect().top;
            offsetLeft = this.canvas.wrapperEl.getBoundingClientRect().left;
            return {
                which: 1,
                shiftKey: e.shiftKey,  // *** Note: added the shiftKey event parameter. ***
                clientX: (e.clientX - offsetLeft) / this.zoom + offsetLeft - this.translate().x,
                clientY: (e.clientY - offsetTop) / this.zoom + offsetTop - this.translate().y,
                pageX: e.pageX - this.translate().x,
                pageY: e.pageY - this.translate().y,
                screenX: e.screenX - this.translate().x,
                screenY: e.screenY - this.translate().y
            };
        };

Cheers,

Rob.