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

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
« no previous file with comments | « ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..694892d8feb5940e91243a5e54c6748cb978ee30 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,37 @@ Polymer({
Polymer.IronMenubarBehavior,
],
+ properties: {
+ ignoreModifiedKeyEvents: {
+ type: Boolean,
+ value: false,
+ },
+ },
+
+ /**
+ * Handler that is called when left arrow key is pressed. Overrides
+ * IronMenubarBehaviorImpl#_onLeftKey.
+ * @param {CustomEvent} event
michaelpg 2016/12/19 10:02:46 ! (since IronMenubarBehaviorImpl assumes it's non-
Dan Beam 2016/12/20 07:07:57 Done.
+ * @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#_onLeftKey.
michaelpg 2016/12/19 10:02:46 onRightKey
Dan Beam 2016/12/20 07:07:57 Done.
+ * @param {CustomEvent} event
michaelpg 2016/12/19 10:02:46 !
Dan Beam 2016/12/20 07:07:57 Done.
+ * @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 +75,15 @@ Polymer({
},
/**
+ * @param {!CustomEvent} event
+ * @return {boolean} Whether the key event has modifier keys pressed.
+ */
+ hasKeyModifiers_: function(event) {
+ var keyEv = /** @type {!KeyboardEvent} */(event.detail.keyboardEvent);
+ return keyEv.altKey || keyEv.ctrlKey || keyEv.metaKey || keyEv.shiftKey;
michaelpg 2016/12/19 10:02:45 maybe it's time for a function in util.js? https:/
Dan Beam 2016/12/20 07:07:56 Done.
+ },
+
+ /**
* 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.
« no previous file with comments | « ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698