Skip to content

Commit

Permalink
[bug-fix] fix issue #17 by temporarily disabling the keypress event l…
Browse files Browse the repository at this point in the history
…isteners for tools keytriggers
  • Loading branch information
weiseng18 committed Sep 2, 2020
1 parent 7fe8497 commit e383856
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/color_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ ColorPicker.prototype.selectColor = function() {
get("color").style.backgroundColor = colorPicked;
}

// turns of keypress event listener for keytriggers, so that typing in RGB/Hex is allowed
ColorPicker.prototype.enableTyping = function() {
tools.toggleKeyPressListener();
}

// creates the area (and structure) to display raw value of the color
ColorPicker.prototype.createDisplayArea = function() {
if (this.colorType == "RGB") {
Expand All @@ -213,6 +218,9 @@ ColorPicker.prototype.createDisplayArea = function() {
ele_input[i].addEventListener("keypress", this.validateRGBKeypress);
ele_input[i].addEventListener("input", this.selectColor.bind(this));
ele_input[i].addEventListener("paste", this.handlePaste.bind(this));

ele_input[i].addEventListener("focus", this.enableTyping);
ele_input[i].addEventListener("blur", this.enableTyping);
}

for (var i=0; i<3; i++) {
Expand All @@ -233,6 +241,9 @@ ColorPicker.prototype.createDisplayArea = function() {
value.addEventListener("input", this.selectColor.bind(this));
value.addEventListener("paste", this.handlePaste.bind(this));

value.addEventListener("focus", this.enableTyping);
value.addEventListener("blur", this.enableTyping);

get("color_text").appendChild(hashsymbol);
get("color_text").appendChild(value);
}
Expand Down

0 comments on commit e383856

Please sign in to comment.