Skip to content

Commit

Permalink
Modified webaudio-controls library
Browse files Browse the repository at this point in the history
- Commented-out all relevant "keydown" event handling
- This disables native keyboard events
- Allowing my new logic to run without any conflicts
  • Loading branch information
Mangoshi committed Apr 21, 2023
1 parent b61473c commit 4e9e944
Showing 1 changed file with 66 additions and 66 deletions.
132 changes: 66 additions & 66 deletions src/webaudio-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,23 +569,23 @@ ${this.basestyle}
if(this._setValue(v) && f)
this.sendEvent("input"),this.sendEvent("change");
}
keydown(e){
const delta = this.step;
if(delta==0)
delta=1;
switch(e.key){
case "ArrowUp":
this.setValue(this.value+delta,true);
break;
case "ArrowDown":
this.setValue(this.value-delta,true);
break;
default:
return;
}
e.preventDefault();
e.stopPropagation();
}
// keydown(e){
// const delta = this.step;
// if(delta==0)
// delta=1;
// switch(e.key){
// case "ArrowUp":
// this.setValue(this.value+delta,true);
// break;
// case "ArrowDown":
// this.setValue(this.value-delta,true);
// break;
// default:
// return;
// }
// e.preventDefault();
// e.stopPropagation();
// }
wheel(e) {
if (!this.enable)
return;
Expand Down Expand Up @@ -752,7 +752,7 @@ ${this.basestyle}
this.ttframe=this.knob.nextSibling;
this.label=this.ttframe.nextSibling;
this.enable=this.getAttr("enable",1);
this.tracking=this.getAttr("tracking","rel");
this.tracking=this.getAttr("tracking","rel");
this._src=this.getAttr("src",opt.sliderSrc); if (!this.hasOwnProperty("src")) Object.defineProperty(this,"src",{get:()=>{return this._src},set:(v)=>{this._src=v;this.setupImage()}});
this._knobsrc=this.getAttr("knobsrc",opt.sliderKnobSrc); if (!this.hasOwnProperty("knobsrc")) Object.defineProperty(this,"knobsrc",{get:()=>{return this._knobsrc},set:(v)=>{this._knobsrc=v;this.setupImage()}});
this._value=this.getAttr("value",0); if (!this.hasOwnProperty("value")) Object.defineProperty(this,"value",{get:()=>{return this._value},set:(v)=>{this._value=v;this.redraw()}});
Expand Down Expand Up @@ -987,23 +987,23 @@ ${this.basestyle}
if(this._setValue(v)&&f)
this.sendEvent("input"),this.sendEvent("change");
}
keydown(e){
const delta = this.step;
if(delta==0)
delta=1;
switch(e.key){
case "ArrowUp":
this.setValue(this.value+delta,true);
break;
case "ArrowDown":
this.setValue(this.value-delta,true);
break;
default:
return;
}
e.preventDefault();
e.stopPropagation();
}
// keydown(e){
// const delta = this.step;
// if(delta==0)
// delta=1;
// switch(e.key){
// case "ArrowUp":
// this.setValue(this.value+delta,true);
// break;
// case "ArrowDown":
// this.setValue(this.value-delta,true);
// break;
// default:
// return;
// }
// e.preventDefault();
// e.stopPropagation();
// }
wheel(e) {
if (!this.enable)
return;
Expand Down Expand Up @@ -1718,36 +1718,36 @@ ${this.basestyle}
this.sendEvent("input"),this.sendEvent("change");
}
wheel(e){}
keydown(e){
let m=Math.floor((this.min+11)/12)*12;
let k=this.keycodes1.indexOf(e.keyCode);
if(k<0) {
k=this.keycodes2.indexOf(e.keyCode);
if(k>=0) k+=12;
}
if(k>=0){
k+=m;
if(this.currentKey!=k){
this.currentKey=k;
this.sendEventFromKey(1,k);
this.setNote(1,k);
}
}
}
keyup(e){
let m=Math.floor((this.min+11)/12)*12;
let k=this.keycodes1.indexOf(e.keyCode);
if(k<0) {
k=this.keycodes2.indexOf(e.keyCode);
if(k>=0) k+=12;
}
if(k>=0){
k+=m;
this.currentKey=-1;
this.sendEventFromKey(0,k);
this.setNote(0,k);
}
}
// keydown(e){
// let m=Math.floor((this.min+11)/12)*12;
// let k=this.keycodes1.indexOf(e.keyCode);
// if(k<0) {
// k=this.keycodes2.indexOf(e.keyCode);
// if(k>=0) k+=12;
// }
// if(k>=0){
// k+=m;
// if(this.currentKey!=k){
// this.currentKey=k;
// this.sendEventFromKey(1,k);
// this.setNote(1,k);
// }
// }
// }
// keyup(e){
// let m=Math.floor((this.min+11)/12)*12;
// let k=this.keycodes1.indexOf(e.keyCode);
// if(k<0) {
// k=this.keycodes2.indexOf(e.keyCode);
// if(k>=0) k+=12;
// }
// if(k>=0){
// k+=m;
// this.currentKey=-1;
// this.sendEventFromKey(0,k);
// this.setNote(0,k);
// }
// }
pointerdown(ev){
this.cv.focus();
if(this.enable) {
Expand Down Expand Up @@ -1790,7 +1790,7 @@ ${this.basestyle}
this.sendevent();
this.redraw();
}

let pointerup=(ev)=>{
if(this.enable) {
if(ev.touches)
Expand Down

0 comments on commit 4e9e944

Please sign in to comment.