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

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

Issue 2260653002: Pin keyboard works with virtual keyboard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
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 9b9ba5dad8b5dc2ba8c528ddea38566061751d5e..55a570b8ab42e4e84a693a05b853f4adcbebe74e 100644
--- a/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js
+++ b/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js
@@ -70,6 +70,15 @@ Polymer({
},
/**
+ * Sets the value of the pin keyboard. Used by the user pod to ensure the
+ * password element has the same value as the pin keyboard.
+ * @param {string} newValue
+ */
+ setNewValue: function(newValue) {
+ this.value = newValue;
jdufault 2016/08/19 01:06:47 We should be able to assign to value directly whic
sammiequon 2016/08/23 17:28:11 Done.
+ },
+
+ /**
* Called when a keypad number has been tapped.
* @param {!{target: !PaperButtonElement}} event
* @private
@@ -77,13 +86,6 @@ Polymer({
onNumberTap_: function(event, detail) {
var numberValue = event.target.getAttribute('value');
this.value += numberValue;
-
- // If a number button is clicked, we do not want to switch focus to the
- // button, therefore we transfer focus back to the input, but if a number
- // button is tabbed into, it should keep focus, so users can use tab and
- // spacebar/return to enter their PIN.
- if (!event.target.receivedFocusFromKeyboard)
- this.focus();
},
/** Fires a submit event with the current PIN value. */
@@ -127,6 +129,42 @@ Polymer({
},
/**
+ * Keypress does not handle backspace but handles the char codes nicely, so we
+ * have a seperate event to process the backspaces.
+ * @param {Event} e Keypress Event object.
+ * @private
+ */
+ onKeyDown_: function(event) {
+ // Backspace pressed.
+ if (event.keyCode == 8) {
+ this.onPinClear_();
+ event.preventDefault();
+ return;
+ }
+ },
+
+ /**
+ * Called when a key press event is fired while the number button is focused.
+ * Ideally we would want to pass focus back to the input element, but the we
+ * cannot or the virtual keyboard will keep poping up.
+ * @param {Event} e Keypress Event object.
+ * @private
+ */
+ onKeyPress_: function(event) {
+ var code = event.keyCode;
+
+ // Enter pressed.
+ if (code == 13) {
+ this.firePinSubmitEvent_();
+ event.preventDefault();
+ return;
+ }
+
+ var stringValue = String.fromCharCode(code);
+ this.value += stringValue;
jdufault 2016/08/19 01:06:47 eliminate stringValue temp
sammiequon 2016/08/23 17:28:11 Done.
+ },
+
+ /**
* Changes the color of the submit button if PIN is ready.
* @param {string} value
* @private

Powered by Google App Engine
This is Rietveld 408576698