You found a bug! We've classified it as a bug in our system. We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Ext User
    Join Date
    Feb 2008
    Posts
    13
    Vote Rating
    0
    kairinsama is on a distinguished road

      0  

    Default [FIXED-598][3.x/2.x] isSpecialKey() does not include the DELETE key

    [FIXED-598][3.x/2.x] isSpecialKey() does not include the DELETE key


    The following mask was preventing the DELETE key from executing normally:

    Code:
    maskRe: /[a-zA-Z\'\- ]/
    Overrode the isSpecialKey function to include DELETE.

    Code:
    Ext.EventObjectImpl.prototype.isSpecialKey = function() {
      var k = this.keyCode;
      k = Ext.isSafari ? (safariKeys[k] || k) : k;
      return (this.type == 'keypress' && this.ctrlKey) ||
        this.isNavKeyPress() ||
        (k == this.BACKSPACE) || // Backspace
        (k == this.DELETE)    || // Delete -- Currently not implemented, can also change 45 to 46 below to include it as well.
        (k >= 16 && k <= 20)  || // Shift, Ctrl, Alt, Pause, Caps Lock
        (k >= 44 && k <= 45);    // Print Screen, Insert
    };
    Last edited by mystix; 11 Sep 2009 at 11:08 AM. Reason: moved to 3.x Bugs from 2.x Bugs

  2. #2
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    checking for keycode 46 is definitely more efficient
    Code:
    Ext.override(Ext.EventObjectImpl, function() {
        var safariKeys = {
            3 : 13, // enter
            63234 : 37, // left
            63235 : 39, // right
            63232 : 38, // up
            63233 : 40, // down
            63276 : 33, // page up
            63277 : 34, // page down
            63272 : 46, // delete
            63273 : 36, // home
            63275 : 35  // end
        };
    
        return {
            normalizeKey : function(k) {
                return Ext.isSafari ? (safariKeys[k] || k) : k;
            },
    
            isSpecialKey : function(){
                var k = this.normalizeKey(this.keyCode);
                return (this.type == 'keypress' && this.ctrlKey) ||
                this.isNavKeyPress() ||
                (k == this.BACKSPACE) || // Backspace
                (k >= 16 && k <= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock
                (k >= 44 && k <= 46);   // Print Screen, Insert, Delete
            }
        }
    }());
    (look ma, no change in filesize!)
    Last edited by mystix; 14 Sep 2009 at 8:06 AM. Reason: edit

  3. #3
    Ext User
    Join Date
    Feb 2008
    Posts
    13
    Vote Rating
    0
    kairinsama is on a distinguished road

      0  

    Default


    Using the Ext.override() instead of overwriting the prototype.isSpecialKey function yields the following result on the key events in a masked field:

    Code:
    // this.normalizeKey is not a function
    
    var k = this.normalizeKey(this.keyCode);\n

  4. #4
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    hmmm.. odd... try the updated override.

  5. #5
    Ext User
    Join Date
    Feb 2008
    Posts
    13
    Vote Rating
    0
    kairinsama is on a distinguished road

      0  

    Default


    Appears to function correctly.

    Results, however, in the following "warnings" in Firefox (3.5.3)

    Code:
    The 'charCode' property of a keydown event should not be used. The value is meaningless.
    The 'charCode' property of a keyup event should not be used. The value is meaningless.

  6. #6
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    Quote Originally Posted by kairinsama View Post
    Appears to function correctly.

    Results, however, in the following "warnings" in Firefox (3.5.3)

    Code:
    The 'charCode' property of a keydown event should not be used. The value is meaningless.
    The 'charCode' property of a keyup event should not be used. The value is meaningless.
    you can ignore those for now. isSpecialKey() was designed to work on either the keydown / keypress / keyup event.

  7. #7
    Ext JS Premium Member
    Join Date
    Mar 2007
    Posts
    70
    Vote Rating
    0
    CableDawg is on a distinguished road

      0  

    Default


    Has this fix been committed for the next release?

  8. #8
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    it's definitely not in yet - i inspected the latest 3.x (and 2.x) codebase from SVN and it still says
    Code:
    // ... [ SNIP ] ...
    
    (k >= 44 && k <= 45);   // Print Screen, Insert
    
    
    // ... [ SNIP ] ...

  9. #9
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    20
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    This is in 2.x and 3.2.x SVN. Due the nature of this change, it will not be in 3.1.x.