Chromium Code Reviews| 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..e6afac9b69377bcb034575ad011d9cbac727109f 100644 |
| --- a/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
| +++ b/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
| @@ -22,6 +22,16 @@ |
| * value="{{pinValue}}"> |
| * </pin-keyboard> |
| */ |
| + |
| +(function() { |
| + |
| +/** |
| + * How long the backspace button must be held down before clearing characters. |
| + * @type {number} |
| + * @const |
| + */ |
| +var repeatClearIntervalMs = 250; |
| + |
| Polymer({ |
| is: 'pin-keyboard', |
| @@ -53,6 +63,15 @@ Polymer({ |
| notify: true, |
| value: '', |
| observer: 'onPinValueChange_' |
| + }, |
| + |
| + /** |
| + * The intervalID used for the backspace button set/clear interval. |
| + * @private |
| + */ |
| + repeatClearIntervalId_: { |
| + type: Number, |
| + value: 0 |
| } |
| }, |
| @@ -97,12 +116,38 @@ 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) { |
| + this.onPinClear_(); |
|
jdufault
2016/09/02 22:58:53
Buttons normally activate on up events, right? Tha
sammiequon
2016/09/03 00:53:49
Done.
|
| + 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_); |
| + this.repeatClearIntervalId_ = 0; |
| + 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 +188,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. |
| @@ -201,3 +251,4 @@ Polymer({ |
| return (document.dir == 'rtl') && !Number.isInteger(+password); |
| }, |
| }); |
| +})(); |