Browse Source

Fixed mouse event name generations in Input.

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

+ 17
- 10
app/js/ui/Input.js View File

mcodes.push(2); mcodes.push(2);
} else if (key.startsWith("mousebtn")){ } else if (key.startsWith("mousebtn")){
var sub = key.substring(8); var sub = key.substring(8);
if (!Number.isNaN(sub)){
if (!isNaN(sub)){
mcodes.push(parseInt(sub)); mcodes.push(parseInt(sub));
} else { } else {
return ""; // This event name does not include valid mouse button code. return ""; // This event name does not include valid mouse button code.
} }


// Now handle keyboard event names. // Now handle keyboard event names.
if (!(key in Object.keys(KEYBYNAME))){
if (!Number.isNaN(key))
else if (!(key in Object.keys(KEYBYNAME))){
if (!isNaN(key))
ecodes.push(parseInt(key)); ecodes.push(parseInt(key));
else else
return ""; // This event name does not include valid key name! return ""; // This event name does not include valid key name!
ecodes.push(KEYBYNAME[key]); ecodes.push(KEYBYNAME[key]);
} }
} }
if (ecodes.length > 0){
ecodes.sort(function(a, b){return a-b;});
mcodes.sort(function(a, b){return a-b;});
return CodesToEventName(ecodes) + CodesToEventName(mcodes);
if (ecodes.length > 0 || mcodes.length > 0){
var rename = "";
if (ecodes.length > 0){
ecodes.sort(function(a, b){return a-b;});
rename = CodesToEventName(ecodes);
}
if (mcodes.length > 0){
mcodes.sort(function(a, b){return a-b;});
rename += ((rename !== "") ? "+" : "") + CodesToEventName(mcodes, true);
}
return rename;
} }
return ""; return "";
} }
var e = ""; var e = "";
for (var i=0; i < this.__mouseButtons.length; i++){ for (var i=0; i < this.__mouseButtons.length; i++){
e += (e !== "") ? "+" : ""; e += (e !== "") ? "+" : "";
switch (this.__mouseButtons[i]){
switch (this.__mouseButtons[i][0]){
case 0: case 0:
e += "mouseleft"; e += "mouseleft";
break; break;
e += "mousemiddle"; e += "mousemiddle";
break; break;
default: default:
e += "mousebtn" + this.__mouseButtons[i].toString();
e += "mousebtn" + this.__mouseButtons[i][0].toString();
} }
} }
return e; return e;
} }
this.__mousePosition = pos; this.__mousePosition = pos;
this.__mouseLastAction = "mousemove"; this.__mouseLastAction = "mousemove";
var ename = MouseEventName();
var ename = MouseEventName("mousemove");
var data = { var data = {
source: this, source: this,
lastX: pos.lastX, lastX: pos.lastX,

Loading…
Cancel
Save