diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-06-03 19:07:49 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-06-03 19:07:49 -0400 |
| commit | 142807d8ea506e792dd662ca67ad3a6d49659b57 (patch) | |
| tree | ef590093c0ad5c6187a5a31697efbf3959994a53 /js | |
| parent | 6cb13ad54e3d807a181285fc7b1befa55b0bc264 (diff) | |
fix some weird focus issues
Diffstat (limited to 'js')
| -rw-r--r-- | js/tool.js | 22 | ||||
| -rw-r--r-- | js/ui/controls.js | 10 |
2 files changed, 30 insertions, 2 deletions
@@ -9,6 +9,7 @@ var Tool = Model({ done: function(){}, focus: function(){ // focused && focused.blur() + console.log("focusing ", this.name) current_tool && current_tool.blur() current_tool = this this.span.classList.add('focused') @@ -17,6 +18,7 @@ var Tool = Model({ }, blur: function(){ current_tool = null + console.log("blurring ", this.name) this.span.classList.remove('focused') this.done() } @@ -37,15 +39,35 @@ var Checkbox = Tool.extend({ var BlurredCheckbox = Checkbox.extend({ focus: function(){ + if (current_tool.name == "shader") { + shader.toggle(false) + current_tool.blur() + current_tool = controls.circle + } this.use() if (this.name != 'shader' && is_desktop) { cursor_input.focus() } + }, + blur: function(){ + console.log("blurring ", this.name) + this.span.classList.remove('focused') + this.done() } }) var BlurredTool = Tool.extend({ focus: function(){ + if (current_tool.name == "shader") { + shader.toggle(false) + current_tool.blur() + current_tool = controls.circle + } this.use() if (this.name != 'shader' && is_desktop) { cursor_input.focus() } + }, + blur: function(){ + console.log("blurring ", this.name) + this.span.classList.remove('focused') + this.done() } }) diff --git a/js/ui/controls.js b/js/ui/controls.js index 6a6c005..81a40e0 100644 --- a/js/ui/controls.js +++ b/js/ui/controls.js @@ -136,7 +136,7 @@ var controls = (function(){ // - ShaderTool = Tool.extend({ + var ShaderTool = Tool.extend({ active: false, use: function(state){ this.active = typeof state == "boolean" ? state : ! this.active @@ -148,7 +148,11 @@ var controls = (function(){ shader_rapper.style.display = "none" } }, - }) + done: function(){ + this.use(false) + console.log("shader done") + } + }) controls.shader = new ShaderTool (shader_el) shader_textarea.value = demo_shader.innerHTML shader_textarea.addEventListener("input", function(){ @@ -159,6 +163,8 @@ var controls = (function(){ controls.animate.use = function(state){ var state = shader.toggle() this.update(state) + controls.shader.focus() + controls.shader.use(true) } controls.experimental_palette = new HiddenCheckbox (experimental_palette_toggle) |
