1. #11
    Sencha User
    Join Date
    May 2007
    Posts
    113
    Vote Rating
    1
    Fabyo is on a distinguished road

      0  

    Thumbs up


    [SOLVED]

    Thank those who helped, the code is working 100%

    thanks

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br">
    <head>
    <title>Enter</title>
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta http-equiv="Content-Language" content="pt-BR" />
    <link href="styles/ext-all.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="scripts/ext-base.js"></script>
        <script type="text/javascript" src="scripts/ext-all.js"></script>
        <script type="text/javascript">    
        
                Ext.onReady(function(){            
                Ext.query('input[@type=text]:first')[0].focus();
                
                new Ext.KeyNav(document, {
                    enter: function(e){
                    var target = e.getTarget();
                    if(target.form){
                        if(target.type == "textarea"){
                            e.setEvent();
                            return false;
                        }
                        
                        e.stopEvent();
                        var els = target.form.elements, len = target.form.length;
                        
                        for(var p = 0; p < len; p++){
                            if(els[p] == target){
                                break;
                            }
                        }
                        for(var i = 1; i < len; i++){
                            var el = els[++p % len];
                            if(el.type == "submit"){
                                target.form.submit();
                            }else if(el.style.display != 'none' && el.style.visibility != 'hidden'
                                    && !el.disabled && !el.getAttribute('readonly')
                                    && !/button|reset|hidden/i.test(el.type)){
                                el.focus();
                                break;
                            }
                        }
                    }
                }
            });
        
    
        });
        </script>
    </head>    
    <body>
    
        <form action="#" name="form" id="form" method="post">
            <label for="campo1">Campo 1 </label><input type="text" name="campo1" id="campo1" /><br />
            <label for="campo2">Campo 2 </label><input type="text" name="campo2" id="campo2" style="display:none;" /><br />
            <label for="campo3">Campo 3 </label><input type="text" name="campo3" id="campo3" disabled="disabled" /><br />
            <label for="campo4">Campo 4 </label><input type="text" name="campo4" id="campo4" style="visibility:hidden" /><br />
            <label for="campo5">Campo 5 </label><input type="text" name="campo5" id="campo5" readonly="readonly" /><br />
            <label for="campo6">Campo 6 </label><input type="checkbox" name="campo6" id="campo6" /><br />
            <label for="campo7">Campo 7 </label><input type="radio" name="campo7" id="campo7" /><br />
            <label for="campo8">Campo 8 </label><input type="text" name="campo8" id="campo8" /><br />
            
            <label for="campo9">Campo 9 </label><textarea name="campo9" id="campo9"></textarea><br />
            
            <label for="campo10">Campo 10 </label><input type="text" name="campo10" id="campo10" /><br />
            
            <input type="submit" name="botao" id="botao" value="Enviar" />
        </form>
    
    </body>
    </html>

  2. #12
    Sencha User
    Join Date
    Sep 2007
    Posts
    6
    Vote Rating
    0
    cmelo is on a distinguished road

      0  

    Exclamation xtype: 'fieldset' Problem

    xtype: 'fieldset' Problem


    This function WORKS great!

    But my form have a lot of fieldset s .

    And this function work junt inside de fildset, to go to another fieldset group we need to use tab ou the mouse.

    What can we do about this problem?

  3. #13
    Sencha User
    Join Date
    May 2007
    Posts
    113
    Vote Rating
    1
    Fabyo is on a distinguished road

      0  

    Default


    Code:
    new Ext.KeyMap(document, {
        key: Ext.EventObject.ENTER,
        fn: function(k,e){
            var el=e.getTarget(null,null,true);
            if(!el.form){return}
            Ext.each(el.form.elements, function(o){
                if ( (parseInt(o.getAttribute('tabIndex')) > parseInt(el.getAttribute('tabIndex'))) && (o.offsetWidth > 0) && !/button|submit|reset|hidden|textarea/i.test(el.type) ){
                    o.focus();
                    return false;
                }
            });
        }
    });
    or use override:

    http://www.extjs.com.br/forum/index....18891#msg18891