From dc1b8738acc40cd1953f5acc455aee2e7f2b7e99 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 20 Jan 2018 15:00:08 +1300 Subject: [PATCH] Migrated the remaining shortcuts --- sources/scripts/core/commander.js | 14 +++++++++++++ sources/scripts/core/keyboard.js | 34 ------------------------------- sources/scripts/ronin.js | 2 ++ 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/sources/scripts/core/commander.js b/sources/scripts/core/commander.js index 3f24486..2666755 100644 --- a/sources/scripts/core/commander.js +++ b/sources/scripts/core/commander.js @@ -118,6 +118,20 @@ function Commander() ronin.commander.update(); } + this.activate = function() + { + ronin.cursor.update(); + ronin.commander.autocomplete(); + ronin.commander.show(); + setTimeout(()=>{ronin.commander.focus},100) + } + + this.deactivate = function() + { + this.blur(); + this.hide(); + } + this.show = function() { this.el.className = "visible"; diff --git a/sources/scripts/core/keyboard.js b/sources/scripts/core/keyboard.js index 3e2c38b..23aaa83 100644 --- a/sources/scripts/core/keyboard.js +++ b/sources/scripts/core/keyboard.js @@ -4,16 +4,6 @@ function Keyboard() this.key_up = function(e) { - if(e.key == "tab" || e.keyCode == 9){ - e.preventDefault(); - ronin.cursor.update(); - ronin.commander.autocomplete(); - ronin.commander.show(); - setTimeout(()=>{ronin.commander.focus},100) - return; - } - - ronin.keyboard.is_down[e.key] = false; ronin.hint.update(e); } @@ -21,34 +11,10 @@ function Keyboard() { ronin.keyboard.is_down[e.key] = true; - if(e.key == "/"){ - e.preventDefault(); - ronin.commander.inject("~") - return; - } - if(e.key == "Enter"){ e.preventDefault(); ronin.commander.validate(); } - - if(e.key == "Escape"){ - e.preventDefault(); - ronin.commander.input_el.blur(); - ronin.commander.input_el.value = ""; - ronin.guide.update(); - ronin.guide.clear(); - ronin.guide.inspect = false; - if(!ronin.commander.is_focused()){ - ronin.commander.hide(); - } - } - - // Macros - if(e.key == "f" && (e.ctrlKey || e.metaKey)){ - e.preventDefault(); - ronin.commander.inject(`frame fill:${ronin.cursor.color}`) - } if(ronin.commander.is_focused()){ ronin.hint.update(e); diff --git a/sources/scripts/ronin.js b/sources/scripts/ronin.js index e423a73..a9889df 100644 --- a/sources/scripts/ronin.js +++ b/sources/scripts/ronin.js @@ -85,6 +85,8 @@ function Ronin() this.controller.add("default","Brush","Dec Size",() => { ronin.brush.mod_size(-1); },"["); this.controller.add("default","Brush","Toggle Color",() => { ronin.cursor.swap_colors(); },"x"); + this.controller.add("default","Commander","Show",() => { ronin.commander.activate(); },"`"); + this.controller.add("default","Commander","Hide",() => { ronin.commander.deactivate(); },"Escape"); this.controller.add("default","Commander","Fill With $",() => { ronin.commander.inject("fill:$"); },"CmdOrCtrl+F"); this.controller.add("default","View","Zoom Reset",() => { ronin.frame.methods.zoom.run(1); },"1");