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

Unified Diff: ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.js

Issue 2586113002: MD Settings: ignore modified key events in the profile avatar grid (Closed)
Patch Set: closure Created 4 years 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: ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.js
diff --git a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.js b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.js
index 8d75dd5598f733a09d923e2c15f51d1655918b37..6db2af2a9445fef73f86efafee5c29ba688d3952 100644
--- a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.js
+++ b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.js
@@ -14,6 +14,39 @@ Polymer({
Polymer.IronMenubarBehavior,
],
+ properties: {
+ ignoreModifiedKeyEvents: {
+ type: Boolean,
+ value: false,
+ },
+ },
+
+ /**
+ * Handler that is called when left arrow key is pressed. Overrides
+ * IronMenubarBehaviorImpl#_onLeftKey and ignores keys likely to be browser
+ * shortcuts (like Alt+Left for back).
+ * @param {!CustomEvent} event
+ * @private
+ */
+ _onLeftKey: function(event) {
+ if (this.ignoreModifiedKeyEvents && this.hasKeyModifiers_(event))
+ return;
+ Polymer.IronMenubarBehaviorImpl._onLeftKey.call(this, event);
+ },
+
+ /**
+ * Handler that is called when right arrow key is pressed. Overrides
+ * IronMenubarBehaviorImpl#_onRightKey and ignores keys likely to be browser
+ * shortcuts (like Alt+Right for forward).
+ * @param {!CustomEvent} event
+ * @private
+ */
+ _onRightKey: function(event) {
+ if (this.ignoreModifiedKeyEvents && this.hasKeyModifiers_(event))
+ return;
+ Polymer.IronMenubarBehaviorImpl._onRightKey.call(this, event);
+ },
+
/**
* Handler that is called when the up arrow key is pressed.
* @param {CustomEvent} event A key combination event.
@@ -44,6 +77,14 @@ Polymer({
},
/**
+ * @param {!CustomEvent} event
+ * @return {boolean} Whether the key event has modifier keys pressed.
+ */
+ hasKeyModifiers_: function(event) {
+ return hasKeyModifiers(assertInstanceof(event.detail.keyboardEvent, Event));
+ },
+
+ /**
* Focuses an item on the same column as the currently focused item and on a
* row below or above the focus row by the given offset. Focus wraps if
* necessary.

Powered by Google App Engine
This is Rietveld 408576698