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 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 User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,050
    Answers
    3976
    Vote Rating
    1381
      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
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  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 User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505
    Vote Rating
    253
      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
  •