1. #1
    Sencha - Training Team mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    682
    Vote Rating
    10
    Answers
    21
    mrsunshine will become famous soon enough

      0  

    Default Unanswered: How to add dag and drop listener to Ext.draw.Sprite?

    Unanswered: How to add dag and drop listener to Ext.draw.Sprite?


    Hi,

    i like to drag and drop Ext.draw.Sprite's on a surface.
    Code:
    var dC = Ext.create('Ext.draw.Component', {
    			height : 500,
    			width : 500,
    			style : 'background: #fff;'
    		});
    		view.add(dC);
    
    		var sprite = dC.surface.add({
    			type: 'circle',
    			fill: '#ff0',
    			radius: 50
    		});
    		dC.surface.renderFrame();
    
    		sprite.on({
    			'click' : function() {
    				console.log(arguments);
    			},
    			'drag' : function() {
    				console.log(arguments);
    			},
    			'touchstart' : function() {
    				console.log(arguments);
    			}
    		});
    i got render the canvas but i get no events from the sprit.

    in the draw guide is an example
    Code:
    // Add a touch listener to the sprite
    myCircle.addListener('touchstart', function() {
        alert('touchstarted!');
    });
    Does anyone succesfully listen on sprite events?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,641
    Vote Rating
    434
    Answers
    3107
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    A sprite doesn't have an element, the surface gets the information from the sprite to draw the item so therefore the sprite won't have interactions, just the surface.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

  3. #3
    Sencha - Training Team mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    682
    Vote Rating
    10
    Answers
    21
    mrsunshine will become famous soon enough

      0  

    Default


    so what do you suggest to do if you want to have several sprites/images which should be positioned by drag and drop on a canvas / surface

  4. #4
    Sencha User
    Join Date
    Feb 2012
    Posts
    3
    Vote Rating
    0
    tonylsg is on a distinguished road

      0  

    Default hum, How to make animation on a component?

    hum, How to make animation on a component?


    so , I also want to know how to do that .
    drawComponent.addListener('mouseup', function() { alert('mouse upped!');
    });

    the drawComponent works fine with the event . how to make a sprite with animation and event listeners?

  5. #5
    Sencha User
    Join Date
    Jun 2012
    Location
    Cologne.Germany
    Posts
    5
    Vote Rating
    2
    ToRoll is on a distinguished road

      0  

    Default how to catch events on sprites via surface ?

    how to catch events on sprites via surface ?


    +1
    Hi,
    I'm also kindly like to ask for any hint on how to get events (e.g. "click") catched from sprites (esp. with ST2.1.0 beta3).
    Don't have a clue on how to get it via surface.

    Thanks for any hint on this.
    Torben