3
* Copyright(c) 2006-2009, Ext JS, LLC.
6
* http://extjs.com/license
11
* <p>Provides a convenient wrapper for normalized keyboard navigation. KeyNav allows you to bind
12
* navigation keys to function calls that will get called when the keys are pressed, providing an easy
13
* way to implement custom navigation schemes for any UI component.</p>
14
* <p>The following are all of the possible keys that can be implemented: enter, left, right, up, down, tab, esc,
15
* pageUp, pageDown, del, home, end. Usage:</p>
17
var nav = new Ext.KeyNav("my-element", {
19
this.moveLeft(e.ctrlKey);
21
"right" : function(e){
22
this.moveRight(e.ctrlKey);
24
"enter" : function(e){
31
* @param {Mixed} el The element to bind to
32
* @param {Object} config The config
34
Ext.KeyNav = function(el, config){
35
this.el = Ext.get(el);
36
Ext.apply(this, config);
43
Ext.KeyNav.prototype = {
45
* @cfg {Boolean} disabled
46
* True to disable this KeyNav instance (defaults to false)
50
* @cfg {String} defaultEventAction
51
* The method to call on the {@link Ext.EventObject} after this KeyNav intercepts a key. Valid values are
52
* {@link Ext.EventObject#stopEvent}, {@link Ext.EventObject#preventDefault} and
53
* {@link Ext.EventObject#stopPropagation} (defaults to 'stopEvent')
55
defaultEventAction: "stopEvent",
57
* @cfg {Boolean} forceKeyDown
58
* Handle the keydown event instead of keypress (defaults to false). KeyNav automatically does this for IE since
59
* IE does not propagate special keys on keypress, but setting this to true will force other browsers to also
60
* handle keydown instead of keypress.
65
prepareEvent : function(e){
67
var h = this.keyToHandler[k];
69
// e.stopPropagation();
71
if(Ext.isSafari2 && h && k >= 37 && k <= 40){
79
var h = this.keyToHandler[k];
81
if(this.doRelay(e, this[h], h) !== true){
82
e[this.defaultEventAction]();
88
doRelay : function(e, h, hname){
89
return h.call(this.scope || this, e);
127
if(this.forceKeyDown || Ext.isIE || Ext.isSafari3 || Ext.isAir){
128
this.el.on("keydown", this.relay, this);
130
this.el.on("keydown", this.prepareEvent, this);
131
this.el.on("keypress", this.relay, this);
133
this.disabled = false;
138
* Disable this KeyNav
142
if(this.forceKeyDown || Ext.isIE || Ext.isSafari3 || Ext.isAir){
143
this.el.un("keydown", this.relay, this);
145
this.el.un("keydown", this.prepareEvent, this);
146
this.el.un("keypress", this.relay, this);
148
this.disabled = true;
b'\\ No newline at end of file'