Pārlūkot izejas kodu

Added Input parameters to access mouse information.

dev-tmpl
Bryan Miller pirms 6 gadiem
vecāks
revīzija
fd9ec031e2
1 mainītis faili ar 30 papildinājumiem un 3 dzēšanām
  1. +30
    -3
      app/js/ui/Input.js

+ 30
- 3
app/js/ui/Input.js Parādīt failu

this.__mouseTarget = null; this.__mouseTarget = null;
this.__mousePosition = null; this.__mousePosition = null;
this.__mouseLastButton = -1; this.__mouseLastButton = -1;
this.__mouseLastButtonAction = "";
this.__mouseLastAction = "";
this.__mouseButtons = []; this.__mouseButtons = [];


this.enableKeyboardInput = (function(){ this.enableKeyboardInput = (function(){
var pos = mousePosition(e); var pos = mousePosition(e);
if (pos.inbounds){ if (pos.inbounds){
this.__mousePosition = pos; this.__mousePosition = pos;
this.__mouseLastAction = "mousemove";
this.__emitter.emit("mousemove", { this.__emitter.emit("mousemove", {
source: this, source: this,
lastX: pos.lastX, lastX: pos.lastX,
if (addMouseButton(button)){ if (addMouseButton(button)){
this.__mousePosition = pos; this.__mousePosition = pos;
this.__mouseLastButton = button; this.__mouseLastButton = button;
this.__mouseLastButtonAction = "mousedown";
this.__mouseLastAction = "mousedown";
this.__emitter.emit("mousedown", { this.__emitter.emit("mousedown", {
source: this, source: this,
lastX: pos.lastX, lastX: pos.lastX,
if (pos.inbounds && diff >= 0){ if (pos.inbounds && diff >= 0){
this.__mousePosition = pos; this.__mousePosition = pos;
this.__mouseLastButton = button; this.__mouseLastButton = button;
this.__mouseLastButtonAction = "mouseup";
this.__mouseLastAction = "mouseup";
this.__emitter.emit("mouseup", { this.__emitter.emit("mouseup", {
source: this, source: this,
lastX: pos.lastX, lastX: pos.lastX,
return KEYMAP["currentcodes"].map(e=>e[0]); return KEYMAP["currentcodes"].map(e=>e[0]);
} }


get lastMouseAction(){
return this.__mouseLastAction;
}

get lastMouseButton(){
return this.__mouseLastButton;
}

get lastMousePosition(){
if (this.__mousePosition === null || this.__mousePosition.lastX === null)
return null;
return {
x: this.__mousePosition.lastX,
y: this.__mousePosition.lastY
};
}

get currentMousePosition(){
if (this.__mousePosition === null)
return null;
return {
x: this.__mousePosition.x,
y: this.__mousePosition.y
};
}

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

Notiek ielāde…
Atcelt
Saglabāt