From 85a2862b92abc75a65ca79e55fb987a1af4bd337 Mon Sep 17 00:00:00 2001 From: timb Date: Sat, 11 Jul 2015 07:09:33 -0700 Subject: make current_filetool (shader, load, save, etc) operate independent of current_tool (brush, fill, etc) --- js/tool.js | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'js/tool.js') diff --git a/js/tool.js b/js/tool.js index 360e79f..c3fc67c 100644 --- a/js/tool.js +++ b/js/tool.js @@ -22,6 +22,27 @@ var Tool = Model({ } }) +var FileTool = Tool.extend({ + + focus: function(){ + if (current_filetool === this) { + this.blur() + return + } + current_filetool && current_filetool.blur() + current_filetool = this + this.span.classList.add('focused') + this.use() + console.log("focus") + if (this.name != 'shader' && is_desktop) { cursor_input.focus() } + }, + blur: function(){ + current_filetool = null + this.span.classList.remove('focused') + this.done() + } +}) + var Checkbox = Tool.extend({ init: function (span){ this.__init(span) @@ -39,13 +60,13 @@ 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 - } + // if (current_filetool && current_filetool.name == "shader") { + // shader.toggle(false) + // current_tool.blur() + // current_tool = controls.circle + // } this.use() - if (this.name != 'shader' && is_desktop) { cursor_input.focus() } + // if (this.name != 'shader' && is_desktop) { cursor_input.focus() } }, blur: function(){ this.span.classList.remove('focused') @@ -55,13 +76,13 @@ var BlurredCheckbox = Checkbox.extend({ var BlurredTool = Tool.extend({ focus: function(){ - if (current_tool.name == "shader") { - shader.toggle(false) - current_tool.blur() - current_tool = controls.circle - } + // if (current_filetool && current_filetool.name == "shader") { + // shader.toggle(false) + // current_tool.blur() + // current_tool = controls.circle + // } this.use() - if (this.name != 'shader' && is_desktop) { cursor_input.focus() } + // if (this.name != 'shader' && is_desktop) { cursor_input.focus() } }, blur: function(){ this.span.classList.remove('focused') -- cgit v1.2.3-70-g09d2