Merge pull request #180 from fsih/modeGuard

Fix null mode issue
This commit is contained in:
DD Liu 2017-11-06 10:17:33 -05:00 committed by GitHub
commit 46ff0bd3e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View file

@ -70,6 +70,7 @@ class BoundingBoxTool {
* @return {boolean} True if there was a hit, false otherwise
*/
onMouseDown (event, clone, multiselect, hitOptions) {
if (event.event.button > 0) return; // only first mouse button
const hitResults = paper.project.hitTestAll(event.point, hitOptions);
if (!hitResults || hitResults.length === 0) {
if (!multiselect) {
@ -113,11 +114,11 @@ class BoundingBoxTool {
return true;
}
onMouseDrag (event) {
if (event.event.button > 0) return; // only first mouse button
if (event.event.button > 0 || !this.mode) return; // only first mouse button
this._modeMap[this.mode].onMouseDrag(event);
}
onMouseUp (event) {
if (event.event.button > 0) return; // only first mouse button
if (event.event.button > 0 || !this.mode) return; // only first mouse button
this._modeMap[this.mode].onMouseUp(event);
this.mode = null;

View file

@ -217,11 +217,11 @@ class ReshapeTool extends paper.Tool {
}
}
handleMouseDrag (event) {
if (event.event.button > 0) return; // only first mouse button
if (event.event.button > 0 || !this.mode) return; // only first mouse button
this._modeMap[this.mode].onMouseDrag(event);
}
handleMouseUp (event) {
if (event.event.button > 0) return; // only first mouse button
if (event.event.button > 0 || !this.mode) return; // only first mouse button
this._modeMap[this.mode].onMouseUp(event);
this.mode = ReshapeModes.SELECTION_BOX;
}

View file

@ -24,11 +24,13 @@ class SelectionBoxTool {
}
}
onMouseDrag (event) {
if (event.event.button > 0) return; // only first mouse button
this.selectionRect = rectSelect(event);
// Remove this rect on the next drag and up event
this.selectionRect.removeOnDrag();
}
onMouseUp (event) {
if (event.event.button > 0) return; // only first mouse button
if (this.selectionRect) {
processRectangularSelection(event, this.selectionRect, this.mode);
this.selectionRect.remove();