From f1f72a20179dff5834d159f72d6dd486c2ff1706 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 5 May 2015 02:34:23 -0400 Subject: check if lost focus, hide selection --- js/matrix.js | 5 ++--- js/ui/controls.js | 1 + js/ui/keys.js | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/matrix.js b/js/matrix.js index 59bad86..bc09099 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -23,8 +23,7 @@ Matrix.prototype.rebuild = function (){ this.append() this.bind() this.generate && this.generate() - // the focused character might disappear after resizing.. - focused = canvas.aa[0][0] + check_if_lost_focus() } Matrix.prototype.clone = function () { var base = this @@ -47,7 +46,7 @@ Matrix.prototype.assign = function (mat) { }) this.append() this.bind() - focused = canvas.aa[0][0] + check_if_lost_focus() return this } diff --git a/js/ui/controls.js b/js/ui/controls.js index 8293a32..fe49527 100644 --- a/js/ui/controls.js +++ b/js/ui/controls.js @@ -92,6 +92,7 @@ var controls = (function(){ controls.grid = new Checkbox (grid_el) controls.grid.use = function(){ + selection.hide() document.body.classList.toggle('grid') this.update( document.body.classList.contains("grid") ) } diff --git a/js/ui/keys.js b/js/ui/keys.js index 7b636b2..fc9a47d 100644 --- a/js/ui/keys.js +++ b/js/ui/keys.js @@ -16,7 +16,7 @@ var keys = (function(){ e.preventDefault() brush.contract(1) brush.modified = false - focused = canvas.aa[0][0] + check_if_lost_focus() break } case 221: // ] @@ -84,3 +84,8 @@ var keys = (function(){ return keys })() + +function check_if_lost_focus() { + if (! focused || ! focused.span) + focused = canvas.aa[0][0] +} \ No newline at end of file -- cgit v1.2.3-70-g09d2