Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Keyup on a TextField/SearchFIeld

  1. #1
    Sencha User arlo.carreon's Avatar
    Join Date
    Jul 2010
    Location
    Orlando, TX
    Posts
    34

    Default Keyup on a TextField/SearchFIeld

    I am using this searchfield:
    Code:
    var searchField = new Ext.form.SearchField({
    	value:'Address OR MLS',
    	cls:'searchfield',
    	listeners: {
    			focus: function(){ searchField.setValue(''); },
    			blur: function(){ if( searchField.getValue()=='' ){ searchField.setValue('Address OR MLS'); } },
    			keyup: function(e){ 
    				// Loop through the object
    				for(var key in e)
    					alert(key+'='+e[key]);
    			}
    			
    		}
    });
    What I am trying to accomplish is to capture what key is being pressed. If the key is the ENTER KEY (13), then I want to do an action. So far I have not been able to get the keyCode for the key pressed.

    The above code is me iterating through the passed parameter, with no luck in finding the keyCode.

    I am sure this is an easy answer, but I have been having trouble with this. Any help would be awesome!

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    The keyup event wasn't passing the event object, which has since been corrected. It will be part of the next release.

    In the interim:

    Code:
    Ext.override(Ext.form.Field, {
        onKeyUp : function(e) {
            this.fireEvent('keyup', this, e);
        }
    });
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3

    Default

    Evan,

    Is this a similar issue to the one where the search field does not seem to be firing the submit function when you press Enter in the field. This seems to be broken in 0.92 and 0.93.

    Robert

  4. #4
    Sencha User arlo.carreon's Avatar
    Join Date
    Jul 2010
    Location
    Orlando, TX
    Posts
    34

    Default

    Evant,

    I have tried the suggested override, but I still do not seem to have access to the keyCode attribute. Besides the suggested override, should I change anything else in this code?

    Code:
    var searchField = new Ext.form.SearchField({
    	value:'Address OR MLS',
    	cls:'searchfield',
    	listeners: {
    			focus: function(){ searchField.setValue(''); },
    			blur: function(){ 	if( searchField.getValue()=='' ){ searchField.setValue('Address OR MLS'); }
    								else{ doQuickSearch( searchField.getValue() ) } 
    							},
    			keyup: function(e){ 
    				alert(e.keyCode);
    			}
    			
    		}
    });
    Thanks.

  5. #5
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    They parameters aren't correct. The first thing passed is the field object, the second argument is the event.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  6. #6

    Question

    I'm having trouble with this as well. I've added in the override suggested above and my code is:

    Code:
           this.standingsTextField = new Ext.form.SearchField({
               id: 'standingsTextField',
               label: 'Search Team',
               flex: .85,
               listeners: {
                   keyup: function(thisField, e) {
                       console.log(e.keyCode);
                   }
               }
           });
    I'm getting undefined in my console log.

    Also, is attaching this keyup listener the only way to detect a keyboard enter on a search field. More specifically, on the ipad keypad for the search field I have the large 'Search' key on the right. Is the only way to utilize this with the keyup listerner?

  7. #7
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    Code:
    console.log(e.browserEvent.keyCode);
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  8. #8
    Sencha User
    Join Date
    Sep 2010
    Location
    Coimbatore
    Posts
    16

    Default

    how to hide the keypad programmatically? is there any event for TextField or FormPanel when the keypad 'Return' or 'Search' or 'Go' pressed?

  9. #9
    Sencha User
    Join Date
    Jul 2010
    Location
    Paris, France
    Posts
    257

    Default

    To test the key on the keypad use this site with an iPhone :
    http://unixpapa.com/js/testkey.html

    The go is ENTER = 13

  10. #10
    Sencha User
    Join Date
    Sep 2010
    Location
    Coimbatore
    Posts
    16

    Default

    thanks a lot. It works very well. I will be very happy if i get any idea about hiding the keypad when the user tap the 'Search' or 'Enter' key in iPhone (also for Android).

Page 1 of 2 12 LastLast

Similar Threads

  1. Extjs Designer - Keyup event in TextField
    By csext2 in forum Ext Designer: Help & Discussion
    Replies: 2
    Last Post: 26 Jul 2010, 12:17 PM
  2. textfield Keyup issue
    By jerrel in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 23 Aug 2009, 6:52 PM
  3. keyup textField event
    By albert.sole in forum Ext 2.x: Help & Discussion
    Replies: 7
    Last Post: 23 Jun 2008, 12:10 PM
  4. [Semi-Solved] keyup not fired on TextField
    By dotnetCarpenter in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 8 Feb 2008, 11:25 AM

Tags for this Thread

Posting Permissions

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