2 * @class Ext.view.BoundListKeyNav
3 * @extends Ext.util.KeyNav
4 * A specialized {@link Ext.util.KeyNav} implementation for navigating a {@link Ext.view.BoundList} using
5 * the keyboard. The up, down, pageup, pagedown, home, and end keys move the active highlight
6 * through the list. The enter key invokes the selection model's select action using the highlighted item.
8 Ext.define('Ext.view.BoundListKeyNav', {
9 extend: 'Ext.util.KeyNav',
10 requires: 'Ext.view.BoundList',
13 * @cfg {Ext.view.BoundList} boundList
15 * The {@link Ext.view.BoundList} instance for which key navigation will be managed. This is required.
18 constructor: function(el, config) {
20 me.boundList = config.boundList;
21 me.callParent([el, Ext.apply({}, config, me.defaultHandlers)]);
27 boundList = me.boundList,
28 allItems = boundList.all,
29 oldItem = boundList.highlightedItem,
30 oldItemIdx = oldItem ? boundList.indexOf(oldItem) : -1,
31 newItemIdx = oldItemIdx > 0 ? oldItemIdx - 1 : allItems.getCount() - 1; //wraps around
32 me.highlightAt(newItemIdx);
37 boundList = me.boundList,
38 allItems = boundList.all,
39 oldItem = boundList.highlightedItem,
40 oldItemIdx = oldItem ? boundList.indexOf(oldItem) : -1,
41 newItemIdx = oldItemIdx < allItems.getCount() - 1 ? oldItemIdx + 1 : 0; //wraps around
42 me.highlightAt(newItemIdx);
49 pagedown: function() {
59 me.highlightAt(me.boundList.all.getCount() - 1);
63 this.selectHighlighted(e);
68 * Highlights the item at the given index.
69 * @param {Number} index
71 highlightAt: function(index) {
72 var boundList = this.boundList,
73 item = boundList.all.item(index);
76 boundList.highlightItem(item);
77 boundList.getTargetEl().scrollChildIntoView(item, false);
82 * Triggers selection of the currently highlighted item according to the behavior of
83 * the configured SelectionModel.
85 selectHighlighted: function(e) {
87 boundList = me.boundList,
88 highlighted = boundList.highlightedItem,
89 selModel = boundList.getSelectionModel();
91 selModel.selectWithEvent(boundList.getRecord(highlighted), e);