From a383e5928000e7f3f2cc49a1158ff94734c390c3 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Sat, 30 Jul 2016 12:04:34 +0200 Subject: [PATCH 01/10] Issue #290: allow to drag selection when using SHIFT while selection --- src/js/Events.js | 3 +++ src/js/selection/SelectionManager.js | 7 +++++++ .../drawing/selection/AbstractDragSelect.js | 6 ++++++ src/js/tools/drawing/selection/BaseSelect.js | 18 ++++++++++++++++ src/js/tools/drawing/selection/ShapeSelect.js | 21 +++++++++++-------- 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/js/Events.js b/src/js/Events.js index dc2b9e16..5241ce03 100644 --- a/src/js/Events.js +++ b/src/js/Events.js @@ -63,6 +63,9 @@ var Events = { SELECTION_CREATED: 'SELECTION_CREATED', SELECTION_MOVE_REQUEST: 'SELECTION_MOVE_REQUEST', SELECTION_DISMISSED: 'SELECTION_DISMISSED', + SELECTION_COPY: 'SELECTION_COPY', + SELECTION_CUT: 'SELECTION_CUT', + SELECTION_PASTE: 'SELECTION_PASTE', SHOW_NOTIFICATION: 'SHOW_NOTIFICATION', HIDE_NOTIFICATION: 'HIDE_NOTIFICATION', diff --git a/src/js/selection/SelectionManager.js b/src/js/selection/SelectionManager.js index 6df6f923..8d8b897f 100644 --- a/src/js/selection/SelectionManager.js +++ b/src/js/selection/SelectionManager.js @@ -17,6 +17,9 @@ $.subscribe(Events.SELECTION_CREATED, $.proxy(this.onSelectionCreated_, this)); $.subscribe(Events.SELECTION_DISMISSED, $.proxy(this.onSelectionDismissed_, this)); $.subscribe(Events.SELECTION_MOVE_REQUEST, $.proxy(this.onSelectionMoved_, this)); + $.subscribe(Events.SELECTION_COPY, this.copy.bind(this)); + $.subscribe(Events.SELECTION_CUT, this.cut.bind(this)); + $.subscribe(Events.SELECTION_PASTE, this.paste.bind(this)); var shortcuts = pskl.service.keyboard.Shortcuts; pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.PASTE, this.paste.bind(this)); @@ -149,6 +152,10 @@ ns.SelectionManager.prototype.onSelectionMoved_ = function(evt, colDiff, rowDiff) { if (this.currentSelection) { this.currentSelection.move(colDiff, rowDiff); + if (evt.shiftKey) { + this.cut(); + this.paste(); + } } else { console.error('Bad state: No currentSelection set when trying to move it in SelectionManager'); } diff --git a/src/js/tools/drawing/selection/AbstractDragSelect.js b/src/js/tools/drawing/selection/AbstractDragSelect.js index 3b9f4ead..7352f6eb 100644 --- a/src/js/tools/drawing/selection/AbstractDragSelect.js +++ b/src/js/tools/drawing/selection/AbstractDragSelect.js @@ -18,6 +18,12 @@ ns.AbstractDragSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) { if (this.hasSelection) { this.hasSelection = false; + + if (this.dragMode_) { + $.publish(Events.SELECTION_PASTE); + this.dragMode_ = false; + } + overlay.clear(); $.publish(Events.SELECTION_DISMISSED); } else { diff --git a/src/js/tools/drawing/selection/BaseSelect.js b/src/js/tools/drawing/selection/BaseSelect.js index 20f6d1d2..ba74c801 100644 --- a/src/js/tools/drawing/selection/BaseSelect.js +++ b/src/js/tools/drawing/selection/BaseSelect.js @@ -48,6 +48,10 @@ this.onSelectStart_(col, row, frame, overlay); } else { this.mode = 'moveSelection'; + if (event.shiftKey && !this.dragMode_) { + this.dragMode_ = true; + $.publish(Events.SELECTION_CUT); + } this.onSelectionMoveStart_(col, row, frame, overlay); } }; @@ -103,6 +107,20 @@ // there is no highlighted pixel for selection tools, do nothing }; + /** + * Protected method, should be called when the selection is dismissed. + */ + ns.BaseSelect.prototype.dismissSelection = function () { + if (this.dragMode_) { + $.publish(Events.SELECTION_PASTE); + this.dragMode_ = false; + } + + // Clean previous selection: + $.publish(Events.SELECTION_DISMISSED); + overlay.clear(); + }; + /** * For each pixel in the selection draw it in white transparent on the tool overlay * @protected diff --git a/src/js/tools/drawing/selection/ShapeSelect.js b/src/js/tools/drawing/selection/ShapeSelect.js index 488a2af6..86f995d6 100644 --- a/src/js/tools/drawing/selection/ShapeSelect.js +++ b/src/js/tools/drawing/selection/ShapeSelect.js @@ -8,6 +8,7 @@ ns.ShapeSelect = function() { ns.BaseSelect.call(this); + this.hasSelection = false; this.toolId = 'tool-shape-select'; this.helpText = 'Shape selection'; @@ -22,16 +23,18 @@ * @override */ ns.ShapeSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) { - // Clean previous selection: - $.publish(Events.SELECTION_DISMISSED); - overlay.clear(); + if (this.hasSelection) { + this.hasSelection = false; + this.dismissSelection(); + } else { + this.hasSelection = true; + // From the pixel cliked, get shape using an algorithm similar to the paintbucket one: + var pixels = pskl.PixelUtils.getSimilarConnectedPixelsFromFrame(frame, col, row); + this.selection = new pskl.selection.ShapeSelection(pixels); - // From the pixel cliked, get shape using an algorithm similar to the paintbucket one: - var pixels = pskl.PixelUtils.getSimilarConnectedPixelsFromFrame(frame, col, row); - this.selection = new pskl.selection.ShapeSelection(pixels); - - $.publish(Events.SELECTION_CREATED, [this.selection]); - this.drawSelectionOnOverlay_(overlay); + $.publish(Events.SELECTION_CREATED, [this.selection]); + this.drawSelectionOnOverlay_(overlay); + } }; })(); From 34f2a9df0be938ef715ed8e30d529a20dfc5a6cd Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Sat, 30 Jul 2016 12:10:23 +0200 Subject: [PATCH 02/10] Issue #163: show highlighter pixel for selection tools when no selection --- src/js/tools/drawing/selection/AbstractDragSelect.js | 2 -- src/js/tools/drawing/selection/BaseSelect.js | 9 +++++---- src/js/tools/drawing/selection/ShapeSelect.js | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/js/tools/drawing/selection/AbstractDragSelect.js b/src/js/tools/drawing/selection/AbstractDragSelect.js index 7352f6eb..4a27fb9e 100644 --- a/src/js/tools/drawing/selection/AbstractDragSelect.js +++ b/src/js/tools/drawing/selection/AbstractDragSelect.js @@ -8,8 +8,6 @@ ns.AbstractDragSelect = function () { ns.BaseSelect.call(this); - - this.hasSelection = false; }; pskl.utils.inherit(ns.AbstractDragSelect, ns.BaseSelect); diff --git a/src/js/tools/drawing/selection/BaseSelect.js b/src/js/tools/drawing/selection/BaseSelect.js index ba74c801..9be22f36 100644 --- a/src/js/tools/drawing/selection/BaseSelect.js +++ b/src/js/tools/drawing/selection/BaseSelect.js @@ -18,6 +18,7 @@ this.lastMoveRow = null; this.selection = null; + this.hasSelection = false; this.tooltipDescriptors = [ {description : 'Drag the selection to move it. You may switch to other layers and frames.'}, @@ -95,6 +96,10 @@ this.bodyRoot.removeClass(this.secondaryToolId); } } + + if (!this.hasSelection) { + pskl.tools.drawing.BaseTool.prototype.moveUnactiveToolAt.apply(this, arguments); + } }; ns.BaseSelect.prototype.isInSelection = function (col, row) { @@ -103,10 +108,6 @@ }); }; - ns.BaseSelect.prototype.hideHighlightedPixel = function() { - // there is no highlighted pixel for selection tools, do nothing - }; - /** * Protected method, should be called when the selection is dismissed. */ diff --git a/src/js/tools/drawing/selection/ShapeSelect.js b/src/js/tools/drawing/selection/ShapeSelect.js index 86f995d6..a1e9765f 100644 --- a/src/js/tools/drawing/selection/ShapeSelect.js +++ b/src/js/tools/drawing/selection/ShapeSelect.js @@ -8,7 +8,6 @@ ns.ShapeSelect = function() { ns.BaseSelect.call(this); - this.hasSelection = false; this.toolId = 'tool-shape-select'; this.helpText = 'Shape selection'; From 0d1210e71f264af3d5855111a4bee1ed29cf2a70 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Sat, 30 Jul 2016 12:19:52 +0200 Subject: [PATCH 03/10] Issue #290: fix wand cursor hotspot --- src/css/tools.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/css/tools.css b/src/css/tools.css index dca84a08..ff54cbf9 100644 --- a/src/css/tools.css +++ b/src/css/tools.css @@ -76,7 +76,7 @@ } .tool-shape-select .drawing-canvas-container:hover { - cursor: url(../img/cursors/wand.png) 15 15, pointer; + cursor: url(../img/cursors/wand.png) 10 5, pointer; } .tool-colorpicker .drawing-canvas-container:hover { From 0d5dc21a4187d038a14f650d7d3c07d3d96d67c9 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Sat, 30 Jul 2016 23:59:24 +0200 Subject: [PATCH 04/10] Issue #290: change boolean flag name to isMovingContent in BaseSelect --- src/js/tools/drawing/selection/AbstractDragSelect.js | 9 +-------- src/js/tools/drawing/selection/BaseSelect.js | 8 ++++---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/js/tools/drawing/selection/AbstractDragSelect.js b/src/js/tools/drawing/selection/AbstractDragSelect.js index 4a27fb9e..59872e62 100644 --- a/src/js/tools/drawing/selection/AbstractDragSelect.js +++ b/src/js/tools/drawing/selection/AbstractDragSelect.js @@ -16,14 +16,7 @@ ns.AbstractDragSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) { if (this.hasSelection) { this.hasSelection = false; - - if (this.dragMode_) { - $.publish(Events.SELECTION_PASTE); - this.dragMode_ = false; - } - - overlay.clear(); - $.publish(Events.SELECTION_DISMISSED); + this.dismissSelection(); } else { this.hasSelection = true; this.onDragSelectStart_(col, row); diff --git a/src/js/tools/drawing/selection/BaseSelect.js b/src/js/tools/drawing/selection/BaseSelect.js index 9be22f36..7f1552a2 100644 --- a/src/js/tools/drawing/selection/BaseSelect.js +++ b/src/js/tools/drawing/selection/BaseSelect.js @@ -49,8 +49,8 @@ this.onSelectStart_(col, row, frame, overlay); } else { this.mode = 'moveSelection'; - if (event.shiftKey && !this.dragMode_) { - this.dragMode_ = true; + if (event.shiftKey && !this.isMovingContent_) { + this.isMovingContent_ = true; $.publish(Events.SELECTION_CUT); } this.onSelectionMoveStart_(col, row, frame, overlay); @@ -112,9 +112,9 @@ * Protected method, should be called when the selection is dismissed. */ ns.BaseSelect.prototype.dismissSelection = function () { - if (this.dragMode_) { + if (this.isMovingContent_) { $.publish(Events.SELECTION_PASTE); - this.dragMode_ = false; + this.isMovingContent_ = false; } // Clean previous selection: From 22797e5dc5baee912f511f9bf38542c83816fc6b Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Sun, 31 Jul 2016 00:00:45 +0200 Subject: [PATCH 05/10] Issue #290: add missing parameter to dismissSelection in BaseSelect --- src/js/tools/drawing/selection/AbstractDragSelect.js | 2 +- src/js/tools/drawing/selection/BaseSelect.js | 2 +- src/js/tools/drawing/selection/ShapeSelect.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/tools/drawing/selection/AbstractDragSelect.js b/src/js/tools/drawing/selection/AbstractDragSelect.js index 59872e62..c6fa9417 100644 --- a/src/js/tools/drawing/selection/AbstractDragSelect.js +++ b/src/js/tools/drawing/selection/AbstractDragSelect.js @@ -16,7 +16,7 @@ ns.AbstractDragSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) { if (this.hasSelection) { this.hasSelection = false; - this.dismissSelection(); + this.dismissSelection(overlay); } else { this.hasSelection = true; this.onDragSelectStart_(col, row); diff --git a/src/js/tools/drawing/selection/BaseSelect.js b/src/js/tools/drawing/selection/BaseSelect.js index 7f1552a2..e6b2ffda 100644 --- a/src/js/tools/drawing/selection/BaseSelect.js +++ b/src/js/tools/drawing/selection/BaseSelect.js @@ -111,7 +111,7 @@ /** * Protected method, should be called when the selection is dismissed. */ - ns.BaseSelect.prototype.dismissSelection = function () { + ns.BaseSelect.prototype.dismissSelection = function (overlay) { if (this.isMovingContent_) { $.publish(Events.SELECTION_PASTE); this.isMovingContent_ = false; diff --git a/src/js/tools/drawing/selection/ShapeSelect.js b/src/js/tools/drawing/selection/ShapeSelect.js index a1e9765f..de2cb09b 100644 --- a/src/js/tools/drawing/selection/ShapeSelect.js +++ b/src/js/tools/drawing/selection/ShapeSelect.js @@ -24,7 +24,7 @@ ns.ShapeSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) { if (this.hasSelection) { this.hasSelection = false; - this.dismissSelection(); + this.dismissSelection(overlay); } else { this.hasSelection = true; // From the pixel cliked, get shape using an algorithm similar to the paintbucket one: From 01aa4629cc536ab87b56f155e350df2f5bab8b6d Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Mon, 1 Aug 2016 09:38:08 +0200 Subject: [PATCH 06/10] Issue #290: Commit selection on ENTER --- src/js/selection/SelectionManager.js | 14 ++++++++++++++ src/js/service/keyboard/KeycodeTranslator.js | 3 ++- src/js/service/keyboard/Shortcut.js | 13 ++++++++++++- src/js/service/keyboard/Shortcuts.js | 5 +++-- src/js/tools/drawing/selection/BaseSelect.js | 4 +++- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/js/selection/SelectionManager.js b/src/js/selection/SelectionManager.js index 8d8b897f..dfb21cbf 100644 --- a/src/js/selection/SelectionManager.js +++ b/src/js/selection/SelectionManager.js @@ -26,6 +26,7 @@ pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.CUT, this.cut.bind(this)); pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.COPY, this.copy.bind(this)); pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.DELETE, this.onDeleteShortcut_.bind(this)); + pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.COMMIT, this.commit.bind(this)); $.subscribe(Events.TOOL_SELECTED, $.proxy(this.onToolSelected_, this)); }; @@ -110,6 +111,19 @@ }); }; + /** + * If the currently selected tool is a selection tool, call dismissSelection handler on + * the current tool instance. + */ + ns.SelectionManager.prototype.commit = function() { + var tool = pskl.app.drawingController.currentToolBehavior; + var isSelectionTool = tool instanceof pskl.tools.drawing.selection.BaseSelect; + if (isSelectionTool) { + var overlay = pskl.app.drawingController.overlayFrame; + tool.dismissSelection(overlay); + } + }; + ns.SelectionManager.prototype.replay = function (frame, replayData) { if (replayData.type === SELECTION_REPLAY.PASTE) { this.pastePixels_(frame, replayData.pixels); diff --git a/src/js/service/keyboard/KeycodeTranslator.js b/src/js/service/keyboard/KeycodeTranslator.js index b5156897..7cd8a293 100644 --- a/src/js/service/keyboard/KeycodeTranslator.js +++ b/src/js/service/keyboard/KeycodeTranslator.js @@ -1,7 +1,7 @@ (function () { var specialKeys = { - 191 : '?', 8 : 'back', + 13 : 'enter', 27 : 'esc', 37 : 'left', 38 : 'up', @@ -20,6 +20,7 @@ 61 : '+', 188 : '<', 190 : '>', + 191 : '?', 219 : '[', 221 : ']' }; diff --git a/src/js/service/keyboard/Shortcut.js b/src/js/service/keyboard/Shortcut.js index beee43c0..31b934f6 100644 --- a/src/js/service/keyboard/Shortcut.js +++ b/src/js/service/keyboard/Shortcut.js @@ -53,7 +53,18 @@ * @return {Boolean} true if the shortcut can be updated */ ns.Shortcut.prototype.isEditable = function () { - return this.getKeys().length < 2; + if (this.getKeys().length === 0) { + // No key defined: can be edited. + return true; + } + + if (this.getKeys().length === 1) { + // Only one key defined, can be edited if it is not using a forbidden key. + return ns.Shortcuts.FORBIDDEN_KEYS.indexOf(this.getKeys()[0]) === -1; + } + + // More than one key, can't be edited. + return false; }; ns.Shortcut.prototype.isCustom = function () { diff --git a/src/js/service/keyboard/Shortcuts.js b/src/js/service/keyboard/Shortcuts.js index 70151fea..c0dc7369 100644 --- a/src/js/service/keyboard/Shortcuts.js +++ b/src/js/service/keyboard/Shortcuts.js @@ -11,7 +11,7 @@ * Or really custom shortcuts such as the 1-9 for color palette shorctus */ FORBIDDEN_KEYS : ['1', '2', '3', '4', '5', '6', '7', '8', '9', '?', 'shift+?', - 'del', 'back', 'ctrl+Y', 'ctrl+shift+Z'], + 'DEL', 'BACK', 'ENTER', 'ctrl+Y', 'ctrl+shift+Z'], /** * Syntax : createShortcut(id, description, default key(s)) @@ -38,7 +38,8 @@ CUT : createShortcut('selection-cut', 'Cut selection', 'ctrl+X'), COPY : createShortcut('selection-copy', 'Copy selection', 'ctrl+C'), PASTE : createShortcut('selection-paste', 'Paste selection', 'ctrl+V'), - DELETE : createShortcut('selection-delete', 'Delete selection', ['del', 'back']) + DELETE : createShortcut('selection-delete', 'Delete selection', ['DEL', 'BACK']), + COMMIT : createShortcut('selection-commit', 'Commit selection', ['ENTER']) }, MISC : { diff --git a/src/js/tools/drawing/selection/BaseSelect.js b/src/js/tools/drawing/selection/BaseSelect.js index e6b2ffda..6999dfd0 100644 --- a/src/js/tools/drawing/selection/BaseSelect.js +++ b/src/js/tools/drawing/selection/BaseSelect.js @@ -23,7 +23,8 @@ this.tooltipDescriptors = [ {description : 'Drag the selection to move it. You may switch to other layers and frames.'}, {key : 'ctrl+c', description : 'Copy the selected area'}, - {key : 'ctrl+v', description : 'Paste the copied area'} + {key : 'ctrl+v', description : 'Paste the copied area'}, + {key : 'shift', description : 'Hold to move the content'} ]; }; @@ -52,6 +53,7 @@ if (event.shiftKey && !this.isMovingContent_) { this.isMovingContent_ = true; $.publish(Events.SELECTION_CUT); + this.drawSelectionOnOverlay_(overlay); } this.onSelectionMoveStart_(col, row, frame, overlay); } From fc7fc6d9b09f506a68a2d009aa466d2b6b0bcd09 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Mon, 1 Aug 2016 09:45:19 +0200 Subject: [PATCH 07/10] Issue #290: Fix typo in comment --- src/js/tools/drawing/selection/ShapeSelect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/tools/drawing/selection/ShapeSelect.js b/src/js/tools/drawing/selection/ShapeSelect.js index de2cb09b..0aa496be 100644 --- a/src/js/tools/drawing/selection/ShapeSelect.js +++ b/src/js/tools/drawing/selection/ShapeSelect.js @@ -27,7 +27,7 @@ this.dismissSelection(overlay); } else { this.hasSelection = true; - // From the pixel cliked, get shape using an algorithm similar to the paintbucket one: + // From the pixel clicked, get shape using an algorithm similar to the paintbucket one: var pixels = pskl.PixelUtils.getSimilarConnectedPixelsFromFrame(frame, col, row); this.selection = new pskl.selection.ShapeSelection(pixels); From 69393127fa3edd2d1ad9c7d245fe8fb0000022ee Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Mon, 1 Aug 2016 11:58:07 +0200 Subject: [PATCH 08/10] Issue #290: rename dismissSelection to commitSelection --- src/js/selection/SelectionManager.js | 4 ++-- src/js/tools/drawing/selection/AbstractDragSelect.js | 2 +- src/js/tools/drawing/selection/BaseSelect.js | 2 +- src/js/tools/drawing/selection/ShapeSelect.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/js/selection/SelectionManager.js b/src/js/selection/SelectionManager.js index dfb21cbf..3e10ec72 100644 --- a/src/js/selection/SelectionManager.js +++ b/src/js/selection/SelectionManager.js @@ -112,7 +112,7 @@ }; /** - * If the currently selected tool is a selection tool, call dismissSelection handler on + * If the currently selected tool is a selection tool, call commitSelection handler on * the current tool instance. */ ns.SelectionManager.prototype.commit = function() { @@ -120,7 +120,7 @@ var isSelectionTool = tool instanceof pskl.tools.drawing.selection.BaseSelect; if (isSelectionTool) { var overlay = pskl.app.drawingController.overlayFrame; - tool.dismissSelection(overlay); + tool.commitSelection(overlay); } }; diff --git a/src/js/tools/drawing/selection/AbstractDragSelect.js b/src/js/tools/drawing/selection/AbstractDragSelect.js index c6fa9417..c5671b5d 100644 --- a/src/js/tools/drawing/selection/AbstractDragSelect.js +++ b/src/js/tools/drawing/selection/AbstractDragSelect.js @@ -16,7 +16,7 @@ ns.AbstractDragSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) { if (this.hasSelection) { this.hasSelection = false; - this.dismissSelection(overlay); + this.commitSelection(overlay); } else { this.hasSelection = true; this.onDragSelectStart_(col, row); diff --git a/src/js/tools/drawing/selection/BaseSelect.js b/src/js/tools/drawing/selection/BaseSelect.js index 6999dfd0..9af0273d 100644 --- a/src/js/tools/drawing/selection/BaseSelect.js +++ b/src/js/tools/drawing/selection/BaseSelect.js @@ -113,7 +113,7 @@ /** * Protected method, should be called when the selection is dismissed. */ - ns.BaseSelect.prototype.dismissSelection = function (overlay) { + ns.BaseSelect.prototype.commitSelection = function (overlay) { if (this.isMovingContent_) { $.publish(Events.SELECTION_PASTE); this.isMovingContent_ = false; diff --git a/src/js/tools/drawing/selection/ShapeSelect.js b/src/js/tools/drawing/selection/ShapeSelect.js index 0aa496be..7e9073ca 100644 --- a/src/js/tools/drawing/selection/ShapeSelect.js +++ b/src/js/tools/drawing/selection/ShapeSelect.js @@ -24,7 +24,7 @@ ns.ShapeSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) { if (this.hasSelection) { this.hasSelection = false; - this.dismissSelection(overlay); + this.commitSelection(overlay); } else { this.hasSelection = true; // From the pixel clicked, get shape using an algorithm similar to the paintbucket one: From f4cbabe2ce32bd53be7bfd8a425e8b4453c6c3c5 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Mon, 1 Aug 2016 19:02:41 +0200 Subject: [PATCH 09/10] Issue #290: selection tools: clear hasSelection flag when calling commitSelection --- src/js/tools/drawing/selection/BaseSelect.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/tools/drawing/selection/BaseSelect.js b/src/js/tools/drawing/selection/BaseSelect.js index 9af0273d..e71eda67 100644 --- a/src/js/tools/drawing/selection/BaseSelect.js +++ b/src/js/tools/drawing/selection/BaseSelect.js @@ -122,6 +122,7 @@ // Clean previous selection: $.publish(Events.SELECTION_DISMISSED); overlay.clear(); + this.hasSelection = false; }; /** From 8e3ac50f81147d1d1c4a995edec73455bbb4b0ff Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Tue, 16 Aug 2016 01:04:55 +0200 Subject: [PATCH 10/10] Issue #290: cleanup unused code in SelectionManager --- src/js/selection/SelectionManager.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/js/selection/SelectionManager.js b/src/js/selection/SelectionManager.js index 3e10ec72..63696e12 100644 --- a/src/js/selection/SelectionManager.js +++ b/src/js/selection/SelectionManager.js @@ -166,10 +166,6 @@ ns.SelectionManager.prototype.onSelectionMoved_ = function(evt, colDiff, rowDiff) { if (this.currentSelection) { this.currentSelection.move(colDiff, rowDiff); - if (evt.shiftKey) { - this.cut(); - this.paste(); - } } else { console.error('Bad state: No currentSelection set when trying to move it in SelectionManager'); }