3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.menu.KeyNav
19 Ext.define('Ext.menu.KeyNav', {
20 extend: 'Ext.util.KeyNav',
22 requires: ['Ext.FocusManager'],
24 constructor: function(menu) {
28 me.callParent([menu.el, {
42 fi = me.menu.focusedItem;
44 if (fi && e.getKey() == Ext.EventObject.DOWN && me.isWhitelisted(fi)) {
53 if (menu.activeItem) {
59 Ext.menu.Manager.hideAll();
62 focusNextItem: function(step) {
65 focusedItem = menu.focusedItem,
66 startIdx = focusedItem ? items.indexOf(focusedItem) : -1,
67 idx = startIdx + step;
69 while (idx != startIdx) {
71 idx = items.length - 1;
72 } else if (idx >= items.length) {
76 var item = items.getAt(idx);
77 if (menu.canActivateItem(item)) {
78 menu.setActiveItem(item);
85 isWhitelisted: function(item) {
86 return Ext.FocusManager.isWhitelisted(item);
91 fi = menu.focusedItem,
94 if (fi && this.isWhitelisted(fi)) {
99 if (menu.parentMenu) {
100 menu.parentMenu.focus();
105 var menu = this.menu,
106 fi = menu.focusedItem,
107 ai = menu.activeItem,
110 if (fi && this.isWhitelisted(fi)) {
115 am = menu.activeItem.menu;
118 Ext.defer(function() {
119 am.setActiveItem(am.items.getAt(0));
137 fi = me.menu.focusedItem;
139 if (fi && e.getKey() == Ext.EventObject.UP && me.isWhitelisted(fi)) {
142 me.focusNextItem(-1);