diff options
| author | timb <opuscule@gmail.com> | 2015-06-10 02:24:04 -0400 |
|---|---|---|
| committer | timb <opuscule@gmail.com> | 2015-06-10 02:24:04 -0400 |
| commit | d57c5121e701004625bfc20d8823df7425938654 (patch) | |
| tree | cdedb416d103ec1a61510762fe97a0774626d80f | |
| parent | ef6613578f3332d8c2fb90fafa5ea089f0dd36b3 (diff) | |
esc can cancel canvas selection if one exists. also, handle esc before controls with raw_key handler so that esc still blurs focus
| -rw-r--r-- | js/ui/keys.js | 15 | ||||
| -rw-r--r-- | js/ui/selection.js | 4 |
2 files changed, 16 insertions, 3 deletions
diff --git a/js/ui/keys.js b/js/ui/keys.js index 739871b..c8df3e8 100644 --- a/js/ui/keys.js +++ b/js/ui/keys.js @@ -9,15 +9,24 @@ var keys = (function(){ if (e.altKey) { document.body.classList.add("dropper") } + + switch (e.keyCode) { + case 27: // esc + if (!selection.hidden && current_canvas === canvas){ + selection.hide() + selection.show() + } else if (focused){ + focused.blur() + } + return + } + if (window.focused && focused.raw_key) { focused.raw_key(e) return } switch (e.keyCode) { - case 27: // esc - if (focused) focused.blur() - break case 219: // [ if (current_tool.name != "text") { e.preventDefault() diff --git a/js/ui/selection.js b/js/ui/selection.js index f818d04..c229019 100644 --- a/js/ui/selection.js +++ b/js/ui/selection.js @@ -71,6 +71,7 @@ var selection = (function(){ b[0] = point[0] b[1] = point[1] reposition(a,b) + selection.hidden = false selector_el.classList.add("creating") } else { copying = false @@ -133,6 +134,8 @@ var selection = (function(){ selector_el.style.left = "-9999px" selector_el.style.width = "0px" selector_el.style.height = "0px" + creating = moving = copying = false + selection.hidden = true selecting = false } @@ -143,6 +146,7 @@ var selection = (function(){ selection.canvas = selection_canvas selection.show = show selection.hide = hide + selection.hidden = true return selection })() |
