X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..f5240829880f87e0cf581c6a296e436fdef0ef80:/docs/source/KeyNav.html diff --git a/docs/source/KeyNav.html b/docs/source/KeyNav.html index 4940fffd..cba9cd86 100644 --- a/docs/source/KeyNav.html +++ b/docs/source/KeyNav.html @@ -1,11 +1,18 @@ - -
-/** + + + ++ \ No newline at end of fileThe source code + + + + +/*! + * Ext JS Library 3.3.0 + * Copyright(c) 2006-2010 Ext JS, Inc. + * licensing@extjs.com + * http://www.extjs.com/license + */ +/** * @class Ext.KeyNav *- +Provides a convenient wrapper for normalized keyboard navigation. KeyNav allows you to bind * navigation keys to function calls that will get called when the keys are pressed, providing an easy @@ -60,19 +67,10 @@ Ext.KeyNav.prototype = { */ forceKeyDown : false, - // private - prepareEvent : function(e){ - var k = e.getKey(); - var h = this.keyToHandler[k]; - if(Ext.isSafari2 && h && k >= 37 && k <= 40){ - e.stopEvent(); - } - }, - // private relay : function(e){ - var k = e.getKey(); - var h = this.keyToHandler[k]; + var k = e.getKey(), + h = this.keyToHandler[k]; if(h && this[h]){ if(this.doRelay(e, this[h], h) !== true){ e[this.defaultEventAction](); @@ -82,7 +80,7 @@ Ext.KeyNav.prototype = { // private doRelay : function(e, h, hname){ - return h.call(this.scope || this, e); + return h.call(this.scope || this, e, hname); }, // possible handlers @@ -114,38 +112,53 @@ Ext.KeyNav.prototype = { 27 : "esc", 9 : "tab" }, + + stopKeyUp: function(e) { + var k = e.getKey(); + + if (k >= 37 && k <= 40) { + // *** bugfix - safari 2.x fires 2 keyup events on cursor keys + // *** (note: this bugfix sacrifices the "keyup" event originating from keyNav elements in Safari 2) + e.stopEvent(); + } + }, + +
/** + * Destroy this KeyNav (this is the same as calling disable). + */ + destroy: function(){ + this.disable(); + }, /** * Enable this KeyNav */ - enable: function(){ - if(this.disabled){ - // ie won't do special keys on keypress, no one else will repeat keys with keydown - // the EventObject will normalize Safari automatically - if(this.isKeydown()){ - this.el.on("keydown", this.relay, this); - }else{ - this.el.on("keydown", this.prepareEvent, this); - this.el.on("keypress", this.relay, this); + enable: function() { + if (this.disabled) { + if (Ext.isSafari2) { + // call stopKeyUp() on "keyup" event + this.el.on('keyup', this.stopKeyUp, this); } - this.disabled = false; - } - }, + + this.el.on(this.isKeydown()? 'keydown' : 'keypress', this.relay, this); + this.disabled = false; + } + }, /** * Disable this KeyNav */ - disable: function(){ - if(!this.disabled){ - if(this.isKeydown()){ - this.el.un("keydown", this.relay, this); - }else{ - this.el.un("keydown", this.prepareEvent, this); - this.el.un("keypress", this.relay, this); + disable: function() { + if (!this.disabled) { + if (Ext.isSafari2) { + // remove "keyup" event handler + this.el.un('keyup', this.stopKeyUp, this); } - this.disabled = true; - } - }, + + this.el.un(this.isKeydown()? 'keydown' : 'keypress', this.relay, this); + this.disabled = true; + } + }, /** * Convenience function for setting disabled/enabled by boolean. @@ -160,6 +173,6 @@ Ext.KeyNav.prototype = { return this.forceKeyDown || Ext.EventManager.useKeydown; } }; -