Browse Source

Added initial code for handling mouse. Nothing functional.

dev-tmpl
Bryan Miller 6 years ago
parent
commit
da3b49763a
1 changed files with 40 additions and 0 deletions
  1. +40
    -0
      app/js/ui/Input.js

+ 40
- 0
app/js/ui/Input.js View File

export default class Input{ export default class Input{
constructor(){ constructor(){
this.__emitter = new EventCaller(); this.__emitter = new EventCaller();
this.__preventDefaults = false;

this.enableKeyboardInput = (function(){ this.enableKeyboardInput = (function(){
var handle_keydown = (function(e){ var handle_keydown = (function(e){
if (AddToKeymap(e.keyCode, "keydown")){ if (AddToKeymap(e.keyCode, "keydown")){
}).bind(this); }).bind(this);
}).apply(this); }).apply(this);


this.enableMouseInput = (function(){
var handle_mousemove = (function(e){
// TODO: Finish me!
}).bind(this);

var handle_mousedown = (function(e){
// TODO: Finish me!
}).bind(this);

var handle_mouseup = (function(e){
// TODO: Finish me!
}).bind(this);

var handle_mousewheel = (function(e){
// TODO: Finish me!
}).bind(this);

return (function(enable){
enable = (enable !== false);
if (enable){
window.addEventListener("mousemove", handle_mousemove);
window.addEventListener("mousedown", handle_mousedown);
window.addEventListener("mouseup", handle_mouseup);
window.addEventListener("mousewheel", handle_mousewheel);
} else {
window.removeEventListener("mousemove", handle_mousemove);
window.removeEventListener("mousedown", handle_mousedown);
window.removeEventListener("mouseup", handle_mouseup);
window.removeEventListener("mousewheel", handle_mousewheel);
}
}).bind(this);
}).apply(this);

this.enableKeyboardInput(); this.enableKeyboardInput();
} }


return KEYMAP["currentcodes"].map(e=>e[0]); return KEYMAP["currentcodes"].map(e=>e[0]);
} }


get preventDefaults(){return this.__preventDefaults;}
set preventDefaults(p){
this.__preventDefaults = (p === true);
}

isKeyDown(key){ isKeyDown(key){
if (typeof(key) === 'string'){ if (typeof(key) === 'string'){
key = KeyNameToCode(key); key = KeyNameToCode(key);

Loading…
Cancel
Save