Results 1 to 2 of 2

Thread: keypress and KeyEvent issues

  1. #1
    Sencha User
    Join Date
    May 2009
    Posts
    72

    Question keypress and KeyEvent issues

    I have a date field and want the user to be able to press "t" and have it fill in todays date. It is working but i cant figure out how to keep the "t" from printing to the screen. e.g. when t is pressed it shows up as 07/13/2009t. Does anyone know how to keep the "t" from showing up?

    Code:
     
    var aDate = new Ext.form.DateField({
     
       name: 'a-date',
       width:95,
       autoheight:true,
       allowBlank:true,
       enableKeyEvents:true,
     
       listeners:{
          change: {
             fn: function(dp,date,dateOld) {
                aDateSelection = date;
             }
          },
          keypress: {
             fn: function(tf,eo){
                var k = eo.getKey();
     
                if (eo.getCharCode() == 116){return false;
                   tf.setValue(new Date());
     
               }
             }
          }
       }
    });
    Thanks in advanced!

  2. #2
    Sencha User
    Join Date
    May 2009
    Posts
    72

    Thumbs up [SOLVED]

    I added the line -

    .preventDefault()

    - to the function and it stops the "t" from printing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •