summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/matrix.js5
-rw-r--r--js/ui/controls.js1
-rw-r--r--js/ui/keys.js7
3 files changed, 9 insertions, 4 deletions
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