From 903f6817cf943f66da613c394a442bfb891e6e94 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Sun, 16 Mar 2014 23:22:47 +0100 Subject: [PATCH] feature : allow to delete current selection * Users can now use DEL to delete the current selection * Cheatsheet has been updated accordingly * Cheatsheet has been refactored to mutualize markup creation code --- src/css/cheatsheet.css | 4 +- src/js/selection/SelectionManager.js | 24 +++-- src/js/service/keyboard/CheatsheetService.js | 100 +++++++++++-------- src/js/service/keyboard/KeycodeTranslator.js | 3 +- src/templates/cheatsheet.html | 4 + 5 files changed, 78 insertions(+), 57 deletions(-) diff --git a/src/css/cheatsheet.css b/src/css/cheatsheet.css index db130301..688a5efe 100644 --- a/src/css/cheatsheet.css +++ b/src/css/cheatsheet.css @@ -17,7 +17,7 @@ width: 100%; height: 100%; box-sizing: border-box; - padding: 20px 10%; + padding: 20px 3%; border-radius: 3px; background: rgba(0,0,0,0.9); overflow: auto; @@ -30,7 +30,7 @@ .cheatsheet-section { float: left; - width : 50%; + width : 33%; } .cheatsheet-shortcut { diff --git a/src/js/selection/SelectionManager.js b/src/js/selection/SelectionManager.js index 578e64b3..7b2e81e0 100644 --- a/src/js/selection/SelectionManager.js +++ b/src/js/selection/SelectionManager.js @@ -16,6 +16,7 @@ pskl.app.shortcutService.addShortcut('ctrl+V', this.paste.bind(this)); pskl.app.shortcutService.addShortcut('ctrl+X', this.cut.bind(this)); pskl.app.shortcutService.addShortcut('ctrl+C', this.copy.bind(this)); + pskl.app.shortcutService.addShortcut('del', this.erase.bind(this)); $.subscribe(Events.TOOL_SELECTED, $.proxy(this.onToolSelected_, this)); }; @@ -46,20 +47,23 @@ this.cleanSelection_(); }; + ns.SelectionManager.prototype.erase = function () { + var pixels = this.currentSelection.pixels; + var currentFrame = this.piskelController.getCurrentFrame(); + for(var i=0, l=pixels.length; iMisc shortcuts +
+

Selection shortcuts

+
    +