Index: chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
diff --git a/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js b/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
index d6c28711b4d28f8981da2fa4aa487e02dafc6e40..24211fc28b842437fbd1fe6f00082abb23a3bdad 100644 |
--- a/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
+++ b/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
@@ -22,6 +22,15 @@ |
* value="{{pinValue}}"> |
* </pin-keyboard> |
*/ |
+ |
+/** |
+ * Time in milliseconds for which the backspace button clears a character when |
jdufault
2016/09/02 20:03:43
What about:
How long the backspace button must
sammiequon
2016/09/02 22:47:39
Done.
|
+ * held down. |
+ * @type {number} |
+ * @const |
+ */ |
+var repeatClearIntervalMs = 250; |
+ |
jdufault
2016/09/02 20:03:44
Make sure to wrap this all in a function to avoid
sammiequon
2016/09/02 22:47:39
Done.
|
Polymer({ |
is: 'pin-keyboard', |
@@ -53,6 +62,14 @@ Polymer({ |
notify: true, |
value: '', |
observer: 'onPinValueChange_' |
+ }, |
+ |
+ /** |
+ * The intervalID used for the backspace button set/clear interval. |
jdufault
2016/09/02 20:03:43
Please add @private
sammiequon
2016/09/02 22:47:39
Done.
|
+ */ |
+ repeatClearIntervalId_: { |
+ type: Number, |
+ value: 0 |
} |
}, |
@@ -97,12 +114,37 @@ Polymer({ |
/** |
* Called when the user wants to erase the last character of the entered |
- * PIN value. |
+ * PIN value. |
*/ |
onPinClear_: function() { |
this.value = this.value.substring(0, this.value.length - 1); |
}, |
+ /** |
+ * Called when the user presses or touches the backspace button. Starts an |
+ * interval callback to repeatedly clear the last pin value until the interval |
+ * is cleared. |
+ * @param {Event} event The event object. |
+ * @private |
+ */ |
+ onBackspaceGetFocus_: function(event) { |
jdufault
2016/09/02 20:03:43
Is there an actual "on-focus" event this could lis
sammiequon
2016/09/02 22:47:39
on-blur and on-foucsout don't seem to trigger on-m
|
+ this.onPinClear_(); |
+ this.repeatClearIntervalId_ = setInterval( |
+ this.onPinClear_.bind(this), repeatClearIntervalMs); |
+ event.preventDefault(); |
+ }, |
+ |
+ /** |
+ * Called when the user unpresses or untouches the backspace button. Stops the |
+ * interval callback. |
+ * @param {Event} event The event object. |
+ * @private |
+ */ |
+ onBackspaceLoseFocus_: function(event) { |
+ clearInterval(this.repeatClearIntervalId_); |
jdufault
2016/09/02 20:03:43
reset repeatClearIntervalId_ value to 0?
sammiequon
2016/09/02 22:47:39
Done.
|
+ event.preventDefault(); |
+ }, |
+ |
/** Called when a key event is pressed while the input element has focus. */ |
onInputKeyDown_: function(event) { |
// Up/down pressed, swallow the event to prevent the input value from |
@@ -143,6 +185,11 @@ Polymer({ |
* @private |
*/ |
onKeyPress_: function(event) { |
+ // If the active element is the input element, the input element itself will |
+ // handle the keypresses, so we do not handle them here. |
+ if (this.shadowRoot.activeElement == this.inputElement) |
+ return; |
+ |
var code = event.keyCode; |
// Enter pressed. |