Results 1 to 4 of 4

Thread: Get the parent object of Ext.draw.Sprite

  1. #1
    Sencha User
    Join Date
    Feb 2009
    Location
    India
    Posts
    73
    Vote Rating
    1
      0  

    Default Unanswered: Get the parent object of Ext.draw.Sprite

    How to get the parent (Ext.draw.Component) for a sprite which referenced was recived from the mouse event.

    It dont have up() method, as it is not component. And it is useless to use the element's up method .
    Code:
    element.el.up('draw')
    Any other way to find the Ext.draw.Component for a sprite from its reference.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,332
    Answers
    3884
    Vote Rating
    1297
      0  

    Default

    The up method on an element is not going to resolve a component, it's going to try and resolve elements.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 2009
    Location
    India
    Posts
    73
    Vote Rating
    1
      0  

    Default

    Sorry, can you explicitly tell how to retrieve the component from sprite object?

    Thanks

  4. #4
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,154
    Answers
    501
    Vote Rating
    247
      0  

    Default

    Try this. If you change the draw component's baseCls then '.x-surface' won't work - you'd need to use whatever you changed the baseCls to, but if you don't change it this should get you the draw component for the clicked (or whatever mouse event) sprite.

    Code:
    var drawComponent = Ext.create('Ext.draw.Component', {
        viewBox: false,
        items: [{
            type: 'circle',
            fill: '#79BB3F',
            radius: 100,
            x: 100,
            y: 100
            , listeners: {
                click: function (sprite, e) {
                    console.log(Ext.getCmp(sprite.el.up('.x-surface').id));
                }
            }
        }]
    });

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
  •