summaryrefslogtreecommitdiff
path: root/js/ui
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-05-11 01:45:36 -0400
committerJules Laplace <jules@okfoc.us>2016-05-11 01:45:36 -0400
commite90ba4585159f0183586b6ac82358b927c709a7e (patch)
treebb1a39ec3d62a6b63d90d2bc011b69b006f87b53 /js/ui
parent792c0fa390fe23efcf98049a14b8e3880987bf30 (diff)
left/right keys work in no/paint mode
Diffstat (limited to 'js/ui')
-rw-r--r--js/ui/keys.js21
-rw-r--r--js/ui/nopaint.js14
2 files changed, 33 insertions, 2 deletions
diff --git a/js/ui/keys.js b/js/ui/keys.js
index ba63fa7..a83ac55 100644
--- a/js/ui/keys.js
+++ b/js/ui/keys.js
@@ -159,6 +159,27 @@ var keys = (function(){
}
}
}
+ keys.left_right_key = function (fn) {
+ return function (e){
+ console.log(e.keyCode)
+ switch (e.keyCode) {
+ case 39: // right
+ e.preventDefault()
+ fn(1)
+ break
+ case 38: // up
+ case 40: // down
+ e.preventDefault()
+ fn(0)
+ break
+ case 37: // left
+ e.preventDefault()
+ fn(-1)
+ break
+ }
+ }
+ }
+
keys.single_numeral_key = function (lex, fn) {
return keys.int_key(function(n, keyCode){
if (n == 0) n = 10
diff --git a/js/ui/nopaint.js b/js/ui/nopaint.js
index 4528cbf..292e83e 100644
--- a/js/ui/nopaint.js
+++ b/js/ui/nopaint.js
@@ -12,12 +12,14 @@ var nopaint = (function(){
controls.paint.use = function(state){
nopaint.play()
nopaint_pause_el.classList.toggle("hidden", false)
+ focused = controls.paint.lex
}
controls.nopaint_pause = new Tool (nopaint_pause_el)
controls.nopaint_pause.use = function(state){
nopaint.pause()
nopaint_pause_el.classList.toggle("hidden", true)
+ focused = canvas.aa[0][0]
}
// use own stepwise clock to drive tweens
@@ -42,7 +44,13 @@ var nopaint = (function(){
nopaint.undo = function(){
undo.undo()
}
- nopaint.pause = function(){
+ controls.paint.lex.raw_key = nopaint.raw_key = keys.left_right_key(function(n){
+ if (! nopaint.timeout) return
+ if (n > 0) nopaint.play()
+ else if (n < 0) nopaint.undo()
+ else nopaint.pause()
+ })
+ nopaint.pause = nopaint.blur = function(){
clearTimeout(nopaint.timeout)
nopaint.timeout = 0
nopaint.step = 0
@@ -60,7 +68,8 @@ var nopaint = (function(){
nopaint.step += 1
}
nopaint.switch_tool = function(){
- undo.new()
+ var state = undo.new()
+ delete state.focus
last_tool = nopaint.tool
last_tool && last_tool.finish()
nopaint.tool = nopaint.get_random_tool()
@@ -403,5 +412,6 @@ var nopaint = (function(){
nopaint.regenerate_weights()
nopaint.toggle(true)
+
return nopaint
})()