浏览代码

Added initial code for handling mouse. Nothing functional.

dev-tmpl
Bryan Miller 6 年前
父节点
当前提交
da3b49763a
共有 1 个文件被更改,包括 40 次插入0 次删除
  1. +40
    -0
      app/js/ui/Input.js

+ 40
- 0
app/js/ui/Input.js 查看文件

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);

正在加载...
取消
保存