1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    13
    Vote Rating
    0
    JackThor is on a distinguished road

      0  

    Default Answered: Tap event on textField

    Answered: Tap event on textField


    Hi so I have a text field component inside my container. I made it so that it is read only, and would like to add a tap event to it. I understand that the text fields does not have a tap event so I looked around and found a possible solution. It works for the most part except that it makes the whole container listen to the tap event, the fireEvent is not working correctly, and I am not sure how fire the event for the specific element tapped. Here is my code. Any help would be great thanks.

    Code:
    Ext.define('GS.view.newEventsView',{
            extend:'Ext.Container',
            xtype:'newEventsView',
            initialize:function(){
                var me = this;
        	me.element.on('tap', 'doBubbleTap', me);
            me.callParent();    
        },
        doBubbleTap : function(e, t) {    
        	this.fireEvent('play', this, e , t);
        },
         tap: function(caller, event, target){
        		console.log(event);
        		console.log(target);
        	},
      }
      // my tool bar goes here and some other items like my field set with my textfield

  2. Looks like your listening directly on the container for the tap event. You should probably just get your textfield and set the listener directly on its element.

    Something like this...

    Code:
       initialize:function(){
            var textField = this.down('textfield');
            textField.element.on({
                tap : function(e){
                    console.log('tapped text field');
                }
            });
        }

  3. #2
    Sencha Premium Member
    Join Date
    Feb 2010
    Location
    Chicago
    Posts
    34
    Vote Rating
    8
    Answers
    10
    Johnny Major will become famous soon enough

      0  

    Default


    Looks like your listening directly on the container for the tap event. You should probably just get your textfield and set the listener directly on its element.

    Something like this...

    Code:
       initialize:function(){
            var textField = this.down('textfield');
            textField.element.on({
                tap : function(e){
                    console.log('tapped text field');
                }
            });
        }

  4. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    13
    Vote Rating
    0
    JackThor is on a distinguished road

      0  

    Default


    thank you.

Thread Participants: 1