Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Touch Premium Member
    Join Date
    Feb 2009
    Posts
    9
    Vote Rating
    0
    dfa is on a distinguished road

      0  

    Default [OPEN-1412] Handling specialKey events for TextField (another way)

    [OPEN-1412] Handling specialKey events for TextField (another way)


    We implement a special number field, which should be usable very comfortable. Due to these proposals we are dependent on a correct specialKey event handling. In the actual Ext version (3.3) there is a different event handling according to which browser you use.

    Our investigations point to following:
    • Chrome: Sends only keyDown when pressing a special key
    • Firefox: Sends keyDown and keyPress when pressing a special key
    • InternetExplorer: Send keyDown when pressing a special key
    • Opera: Sends keyDown and keyPress when pressing a special key. Sometimes (e.g. '-' on number block) it sends a keyDown event followed by two (yes two!) keyPress events.

    We tried to solve this problem that way:

    Code:
    Ext.override(Ext.form.TextField, {
        keyDownCode:'',
    
        onKeyDown:function(e){
            var charCode = e.charCode ? e.charCode : e.keyCode;
            this.keyDownCode = charCode;
            this.fireEvent('keydown', this, e);
            if (Ext.isGecko === false && Ext.isOpera === false) {
                if ((charCode === 8) || 
                    (charCode === 9) || 
                    (charCode === 13) || 
                    (charCode === 127) || 
                    (charCode >= 33 && charCode <= 40) ||
                    (charCode >= 44 && charCode <= 46)) {
                    this.fireEvent('specialkey', this, e);
                    this.keyDownCode = '';
                    return;
                }
            }
        },
    
        onKeyPress:function(e){
            var charCode = e.charCode ? e.charCode : e.keyCode;
            if (Ext.isGecko === true || Ext.isOpera === true) {
                if (charCode === this.keyDownCode) {
                    this.keyDownCode = '';
                    if (Ext.isOpera === true && e.browserEvent.which > 0) {
                        // Opera sends keys like '-' in the number block as
                        // 'keydown, keypress, keypress' sequence. The first
                        // sequence 'keydown, keypress' has to be ignored.
                        return;
                    }
                    this.fireEvent('specialkey', this, e);
                    return;
                }
            }
            this.fireEvent('keypress', this, e);
        }
    
    });
    If you - the ExtJs development team - think this is a way, feel free to integrate it.

    Best regards,
    Dom

  2. #2
    Touch Premium Member
    Join Date
    Feb 2009
    Posts
    9
    Vote Rating
    0
    dfa is on a distinguished road

      0  

    Default


    Oops, I forgot three lines of code:

    Code:
    Ext.override(Ext.form.Field, {
        fireKey:function(e){
        }
    });
    We have to deactivate the fireKey event.

  3. #3
    Touch Premium Member
    Join Date
    Feb 2009
    Posts
    9
    Vote Rating
    0
    dfa is on a distinguished road

      0  

    Default


    Sorry for these multiple updates. The actual version:

    Code:
    Ext.override(Ext.form.Field, {
        fireKey:function(e){
        }
    });
    
    Ext.override(Ext.form.TextField, {
        keyDownCode:'',
    
        isSpecialKey:function(keyCode){
            if (this.isSpecialKeyNonPrintable(keyCode) === true) {
                return true;
            }
            return this.isSpecialKeyPrintable(keyCode);
        },
    
        isSpecialKeyNonPrintable:function(keyCode){
            return ((keyCode === 8) || 
                    (keyCode === 9) || 
                    (keyCode === 13) || 
                    (keyCode === 127));
    
        },
    
        isSpecialKeyPrintable:function(keyCode){
            return ((keyCode >= 33 && keyCode <= 40) ||
                    (keyCode >= 44 && keyCode <= 46));
        },
    
        onKeyDown:function(e){
            var charCode = e.charCode ? e.charCode : e.keyCode;
            this.keyDownCode = charCode;
            this.fireEvent('keydown', this, e);
            if (Ext.isGecko === false && Ext.isOpera === false) {
                if (this.isSpecialKey(charCode) === true) {
                    this.fireEvent('specialkey', this, e);
                    this.keyDownCode = '';
                    return;
                }
            }
        },
    
        onKeyPress:function(e){
            var charCode = e.charCode ? e.charCode : e.keyCode;
            if (Ext.isGecko === true || Ext.isOpera === true) {
                if ((charCode === this.keyDownCode) &&
                    (this.isSpecialKey(charCode) === true)) {
                    this.keyDownCode = '';
                    if (Ext.isOpera === true && e.browserEvent.which > 0 && this.isSpecialKeyPrintable(charCode) === true) {
                        // Opera sends keys like '-' in the number block as
                        // 'keydown, keypress, keypress' sequence. The first
                        // sequence 'keydown, keypress' has to be ignored.
                        return;
                    }
                    this.fireEvent('specialkey', this, e);
                    return;
                }
            }
            this.fireEvent('keypress', this, e);
        }
    
    });

Similar Threads

  1. TextField not working as expected when using maskRe and specialkey
    By sk205 in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 11 Oct 2010, 3:05 AM
  2. Replies: 6
    Last Post: 2 Jul 2010, 12:32 AM
  3. Replies: 0
    Last Post: 26 Mar 2010, 3:10 AM
  4. specialkey event not working in a TextField
    By jrfuentesh in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 2 Jul 2009, 6:22 AM
  5. [2.0a1] TextField and specialkey event concerning backspace key
    By rednix in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 6 Oct 2007, 4:32 PM
Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi