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)) {
52 focused = menu.focusedItem;
54 if (menu.activeItem) {
56 } else if (focused && focused.isFormField) {
57 // prevent stopEvent being called
63 Ext.menu.Manager.hideAll();
66 focusNextItem: function(step) {
69 focusedItem = menu.focusedItem,
70 startIdx = focusedItem ? items.indexOf(focusedItem) : -1,
71 idx = startIdx + step;
73 while (idx != startIdx) {
75 idx = items.length - 1;
76 } else if (idx >= items.length) {
80 var item = items.getAt(idx);
81 if (menu.canActivateItem(item)) {
82 menu.setActiveItem(item);
89 isWhitelisted: function(item) {
90 return Ext.FocusManager.isWhitelisted(item);
95 fi = menu.focusedItem,
98 if (fi && this.isWhitelisted(fi)) {
103 if (menu.parentMenu) {
104 menu.parentMenu.focus();
109 var menu = this.menu,
110 fi = menu.focusedItem,
111 ai = menu.activeItem,
114 if (fi && this.isWhitelisted(fi)) {
119 am = menu.activeItem.menu;
122 Ext.defer(function() {
123 am.setActiveItem(am.items.getAt(0));
141 fi = me.menu.focusedItem;
143 if (fi && e.getKey() == Ext.EventObject.UP && me.isWhitelisted(fi)) {
146 me.focusNextItem(-1);