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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_menu.js

Issue 2144873002: Support first letter navigation in Panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 4 years, 5 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/chromevox/cvox2/background/panel_menu.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_menu.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_menu.js
index f8c75b21236f1b98af4f2c7d1314064084ddb070..d94914cc95c64be2f4468eed54396cf05dac01cc 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_menu.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_menu.js
@@ -62,6 +62,9 @@ PanelMenu = function(menuMsg) {
* @private
*/
this.activeIndex_ = -1;
+
+ this.menuElement.addEventListener(
+ 'keypress', this.onKeyPress_.bind(this), true);
};
PanelMenu.prototype = {
@@ -187,6 +190,20 @@ PanelMenu.prototype = {
return this.items_[i].callback;
}
return null;
+ },
+
+ /**
+ * Handles key presses for first letter accelerators.
+ */
+ onKeyPress_: function(evt) {
+ var query = String.fromCharCode(evt.charCode).toLowerCase();
+
+ for (var i = this.activeIndex_ + 1; i < this.items_.length; i++) {
+ if (this.items_[i].text.toLowerCase().indexOf(query) == 0) {
+ this.activateItem(i);
+ break;
+ }
+ }
}
};

Powered by Google App Engine
This is Rietveld 408576698