You found a bug! We've classified it as TOUCH-3692 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Feb 2012
    Location
    Kyiv, Ukraine
    Posts
    6
    Vote Rating
    0
    Igor Lapiga is on a distinguished road

      0  

    Default Label with tap event and onPainted

    Label with tap event and onPainted


    Hello,

    I need label with tap event. I use this code in view:
    Code:
    items:[{
    xtype: 'label',
    listeners : {
      single : true,
      painted : function(component) {
        //in ST 2.0
        //component.element.on('tap', function(e, t) { component.fireEvent('tap', component, e, t); }, component);
        //in ST 2.1
        var element = component,
              component = this;
        element.on('tap', function(e, t) { component.fireEvent('tap', component, e, t); }, component);
      }
    }]
    In ST 2.0 handler's parameter component = this = "my label".
    Now, in ST 2.1 handler's parameter component is element("my label".element) and this = "my label".
    Is this correct?
    I think the documentation for Component painted event is incorrect.
    http://docs.sencha.com/touch/2-1/#!/...-event-painted

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    That is true and I will open a bug however there is a better way to do what you are wanting to do:

    Code:
    Ext.Viewport.add({
        items : [
            {
                xtype     : 'label',
                html      : 'I am a label',
                listeners : {
                    element : 'element',
                    tap     : function(e, t) {
                        this.fireEvent('tap', this, e, t);
                    }
                }
            }
        ]
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Location
    Kyiv, Ukraine
    Posts
    6
    Vote Rating
    0
    Igor Lapiga is on a distinguished road

      0  

    Default


    This is perfect! Thank you!

Thread Participants: 1