Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2108)

Unified Diff: chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js

Issue 2302483003: Pin keyboard improvements. (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9843ef239cade01bcdf2f38f1928877e5a1667a7 100644
--- a/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js
+++ b/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js
@@ -53,6 +53,23 @@ Polymer({
notify: true,
value: '',
observer: 'onPinValueChange_'
+ },
+
+ /**
+ * The intervalID used for the backspace button set/clear interval.
+ */
+ intervalId: {
jdufault 2016/08/31 19:28:55 Can we use this.async?
sammiequon 2016/08/31 22:30:32 Done.
+ type: Number,
+ value: 0
+ }
+
+ /**
+ * When the backspace button is held down, it repeatly clears the last
+ * character of the input value every intervalMs.
+ */
+ intervalMs: {
+ type: Number,
+ value: 150
}
},
@@ -97,12 +114,34 @@ 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 the backspace button. Starts a interval
+ * callback to repeatedly clear the last pin value until the interval is
+ * cleared.
+ * @private
+ */
+ onBackspaceMouseDown_: function() {
+ this.onPinClear_();
+ intervalId = setInterval(function() {
jdufault 2016/08/31 19:28:55 this.intervalId_
sammiequon 2016/08/31 22:30:32 Done.
+ this.onPinClear_();
+ }.bind(this), this.intervalMs);
+ },
+
+ /**
+ * Called when the user unpresses the backspace button. Stops the interval
+ * callback.
+ * @private
+ */
+ onBackspaceMouseUpLeave_: function() {
jdufault 2016/08/31 19:28:55 Does this work for tapping?
sammiequon 2016/08/31 22:30:32 Yes.
+ clearInterval(intervalId);
jdufault 2016/08/31 19:28:55 this.intervalId_
sammiequon 2016/08/31 22:30:32 Done.
+ },
+
/** 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 +182,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.

Powered by Google App Engine
This is Rietveld 408576698