new command ~, toggles commander to always show. also patch mousedown + add .gitignore

This commit is contained in:
Alexander Cobleigh 2016-11-17 20:37:45 +01:00
parent 334f3c980e
commit 7af3b0fb39
3 changed files with 20 additions and 6 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.swp
*.swo

View File

@ -5,16 +5,23 @@ function Commander(element,element_input)
this.cmd = null; this.cmd = null;
this.storage = []; this.storage = [];
this.storage_index = 0; this.storage_index = 0;
this.always_show = false;
this.show = function() this.show = function()
{ {
this.element.setAttribute('class','visible'); this.element.setAttribute('class','visible');
this.element_input.focus(); this.element_input.focus();
} }
this.always = function() {
this.always_show = !this.always_show;
}
this.hide = function() this.hide = function()
{ {
this.element.setAttribute('class','hidden'); if (!this.always_show) {
this.element.setAttribute('class','hidden');
}
this.element_input.value = ""; this.element_input.value = "";
} }
@ -45,6 +52,9 @@ function Commander(element,element_input)
var cmd = new Command(content); var cmd = new Command(content);
switch(key) { switch(key) {
case "~":
this.always();
break;
case "@": case "@":
ronin.canvas.active(cmd); ronin.canvas.active(cmd);
break; break;
@ -127,4 +137,4 @@ function Commander(element,element_input)
break; break;
} }
} }
} }

View File

@ -7,9 +7,11 @@ var commander = new Commander(document.getElementById("commander"),document.getE
// Interactive // Interactive
document.addEventListener('mousemove', function(e) { ronin.brush.draw(e); }, false); document.addEventListener('mousemove', function(e) { ronin.brush.draw(e); ;
document.addEventListener('mousedown', function(e) { if(e.which != 1){ return; } ronin.brush.draw_start(e); }, false); }, false);
document.addEventListener('mouseup', function(e) { ronin.brush.draw_stop(e); }, false); document.addEventListener('mousedown', function(e) { if(e.which != 1){ return; } ronin.brush.draw_start(e); ronin.brush.draw(e) }, false);
document.addEventListener('mouseup', function(e) { ronin.brush.draw_stop(e); document.getElementById("commander_input").focus();}, false);
var keyboard = new Keyboard(); var keyboard = new Keyboard();
document.onkeyup = function myFunction(){ keyboard.listen(event); }; document.onkeyup = function myFunction(){ keyboard.listen(event); };