You found a bug! We've classified it as a bug in our system. We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    796
    Vote Rating
    29
    LesJ will become famous soon enough LesJ will become famous soon enough

      0  

    Default [FIXED-EXTJSIV-1769][4] Ext.draw - can't create draggable sprite

    [FIXED-EXTJSIV-1769][4] Ext.draw - can't create draggable sprite


    I'm getting an error when I try to create a draggable sprite.

    lineNumber 54546
    message "me.surface.createSprite is not a function"
    name "TypeError"

    Works fine when draggable: false.

    Code:
    var drawComponent = Ext.create('Ext.draw.Component', {
        viewBox: false,
        items: [{
            type: 'path',
            id: "item_1",
            group: "path",
            stroke: "blue",
            "stroke-width": 3,
            draggable: true,
            fill: "red",
            path: 'M60 10L100 10L100 50L60 50L60 10Z'
        }]
    });
    
    Ext.create('Ext.Window', {
        width: 300,
        height: 300,
        layout: 'fit',
        items: [drawComponent]
    }).show();

  2. #2
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,626
    Vote Rating
    2
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    message is right, there is no function createSprite, only createItem (and this is commented as temporary)
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5
    energlobe.de - german online magazine

  3. #3
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,626
    Vote Rating
    2
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    ok, createSrite should be available in Svg or Vml after creating the surface. But it isn't at this point.
    Even when i call initDraggable manually, it fails now, worked well in B3:

    PHP Code:
    Ext.define('Shaper.Window', {
        
    extend'Ext.window.Window',
        
    alias'widget.shaperWindow',


        
    initComponent: function() {
            var 
    canvas Ext.create('Ext.draw.Component', {
                
    viewBoxfalse,
                
    itemId'canvas'

            
    });
            
    Ext.apply(this, {
                
    title'Sprites',
                
    width600,
                
    height400,
                
    x200,
                
    y200,
                
    layout'fit',
                
    hiddenfalse,
                
    maximizabletrue,
                
    renderToExt.getBody(),
                
    items: [canvas],
                
    dockedItems: [
                    {
                        
    xtype'toolbar',
                        
    dock'top',
                        
    items: [
                            {
                                
    text'Circle',
                                
    itemId'cCircle',
                                
    scopethis,
                                
    handlerthis.drawShape
                            
    },
                            {
                                
    text'Rect',
                                
    itemId'cRect',
                                
    scopethis,
                                
    handlerthis.drawShape
                            
    },
                            {
                                
    text'Text',
                                
    itemId'cText',
                                
    scopethis,
                                
    handlerthis.drawShape
                            
    },
                            {
                                
    text'Path',
                                
    itemId'cPath',
                                
    scopethis,
                                
    handlerthis.drawShape
                            
    },
                            {
                                
    text'Line',
                                
    itemId'cLine',
                                
    scopethis,
                                
    handlerthis.drawShape
                            
    },
                            {
                                
    text'Polyline',
                                
    itemId'cPolyline',
                                
    scopethis,
                                
    handlerthis.drawShape
                            
    },
                            {
                                
    text'Polygon',
                                
    itemId'cPolygon',
                                
    scopethis,
                                
    handlerthis.drawShape
                            
    },
                            
    '->',
                            {
                                
    text'clear all',
                                
    scopethis,
                                
    handlerthis.clearCanvas
                            
    }
                        ]}
                ]
            });
            
    this.callParent();
        },
        
    drawShape: function(button) {
            var 
    sprite nullcanvas this.down('#canvas'), xy;
            switch (
    button.itemId) {
                case 
    'cCircle':
                    
    sprite = new Ext.draw.Sprite({
                        
    type'circle',
                        
    x50,
                        
    y160,
                        
    radius50,
                        
    fill'red',
                        
    draggablefalse
                    
    });
                    break;
                case 
    'cRect':
                    
    sprite = new Ext.draw.Sprite({
                        
    type'rect',
                        
    x150,
                        
    y160,
                        
    width60,
                        
    height60,
                        
    fill'blue',
                        
    draggablefalse
                    
    });
                    break;
                case 
    'cText':
                    
    sprite = new Ext.draw.Sprite({
                        
    type'text',
                        
    x200,
                        
    y60,
                        
    width160,
                        
    height40,
                        
    text'Text-Sprite',
                        
    font'12px Arial',
                        
    'stroke-width'4,
                        
    fill'green',
                        
    draggablefalse
                    
    });
                    break;
                case 
    'cPath':
                    
    sprite = new Ext.draw.Sprite({
                        
    type'path',
                        
    path'M27.998,2.266c-2.12-1.91-6.925,0.382-9.575,1.93c-0.76-0.12-1.557-0.185-2.388-0.185c-3.349,0-6.052,0.985-8.106,2.843c-2.336,2.139-3.631,4.94-3.631,8.177c0,0.028,0.001,0.056,0.001,0.084c3.287-5.15,8.342-7.79,9.682-8.487c0.212-0.099,0.338,0.155,0.141,0.253c-0.015,0.042-0.015,0,0,0c-2.254,1.35-6.434,5.259-9.146,10.886l-0.003-0.007c-1.717,3.547-3.167,8.529-0.267,10.358c2.197,1.382,6.13-0.248,9.295-2.318c0.764,0.108,1.567,0.165,2.415,0.165c5.84,0,9.937-3.223,11.399-7.924l-8.022-0.014c-0.337,1.661-1.464,2.548-3.223,2.548c-2.21,0-3.729-1.211-3.828-4.012l15.228-0.014c0.028-0.578-0.042-0.985-0.042-1.436c0-5.251-3.143-9.355-8.255-10.663c2.081-1.294,5.974-3.209,7.848-1.681c1.407,1.14,0.633,3.533,0.295,4.518c-0.056,0.254,0.24,0.296,0.296,0.057C28.814,5.573,29.026,3.194,27.998,2.266zM13.272,25.676c-2.469,1.475-5.873,2.539-7.539,1.289c-1.243-0.935-0.696-3.468,0.398-5.938c0.664,0.992,1.495,1.886,2.473,2.63C9.926,24.651,11.479,25.324,13.272,25.676zM12.714,13.046c0.042-2.435,1.787-3.49,3.617-3.49c1.928,0,3.49,1.112,3.49,3.49H12.714z',
                        
    fill'rgb(156, 178, 248)',
                        
    x100,
                        
    y20,
                        
    draggablefalse,
                        
    scale: {
                            
    x10,
                            
    y10
                        
    }

                    });
                    break;
                case 
    'cLine':
                    
    sprite = new Ext.draw.Sprite({
                        
    type'line',
                        
    x0,
                        
    y0,
                        
    x1300,
                        
    y1300,
                        
    stroke'#000000',
                        
    'stroke-width'2,
                        
    draggablefalse
                    
    });
                    break;
                case 
    'cPolygon':
                    
    sprite = new Ext.draw.Sprite({
                        
    type'polygon',
                        
    points'60,0 120,0 180,60 180,120 120,180 60,180 0,120 0,60',
                        
    fill'red',
                        
    draggablefalse
                    
    });
                    break;
            }
            if (
    sprite) {
                
    canvas.surface.add(sprite);
                
    sprite.initDraggable();
                
    sprite.show(true);
            }
        },
        
    clearCanvas: function() {
            var 
    surface this.down('#canvas').surface;
            
    surface.removeAll();
        }
    });

    Ext.onReady(function() {
        
    Ext.widget('shaperWindow', {}).show();
    }); 
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5
    energlobe.de - german online magazine

  4. #4
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,659
    Vote Rating
    14
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Thank you for the report, this has been fixed for the next release.

  5. #5
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    796
    Vote Rating
    29
    LesJ will become famous soon enough LesJ will become famous soon enough

      0  

    Default This is still not fixed

    This is still not fixed


    This is still not fixed in 4.0.1.

    Use the same example that I provided. You will get an error in Firefox 4:

    Code:
    TypeError: this.el is undefined
    [Break On This Error] if (this.el.dom.childNodes[idx...by 2 to account for defs and bg rect
    Svg.js (line 552)
    Comment out 'draggable: true' and the error disappears.
    Last edited by LesJ; 19 May 2011 at 7:16 AM. Reason: Add release info

  6. #6
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    796
    Vote Rating
    29
    LesJ will become famous soon enough LesJ will become famous soon enough

      0  

    Default More code

    More code


    I modified the example and now it works in FF 4, but see what happens in IE7. The sprite disappears when you try to drag it.

    Code:
    var drawComponent = Ext.create('Ext.draw.Component', {
        viewBox: false,
        items: []
    });
    
    Ext.create('Ext.Window', {
        width: 300,
        height: 300,
        layout: 'fit',
        items: [drawComponent]
    }).show();
    
    drawComponent.surface.add({
            type: 'path',
            id: "item_1",
            group: "path",
            stroke: "blue",
            "stroke-width": 3,
            draggable: true,
            fill: "red",
            path: 'M60 10L100 10L100 50L60 50L60 10Z'
        }).show(true);

  7. #7
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    796
    Vote Rating
    29
    LesJ will become famous soon enough LesJ will become famous soon enough

      0  

    Default


    Using 4.0.2 RC3... dragging still doesn't work in IE7 ( I didn't try other IE versions). Use the code is post #6 to recreate this problem.

  8. #8
    Sencha User
    Join Date
    Apr 2011
    Posts
    16
    Vote Rating
    0
    utkarshgaur is on a distinguished road

      0  

    Default I am using 4.1 and this still doesn't work

    I am using 4.1 and this still doesn't work


    Any fixes? and why does the title say FIXED? this isn't fixed.

    Error in chrome:

    "Cannot read property 'dom' of undefined"

    (in applyZindex, called by createSpriteElement)
    Last edited by utkarshgaur; 17 Aug 2012 at 11:33 AM. Reason: added error message

Similar Threads

  1. Replies: 0
    Last Post: 17 Apr 2011, 4:30 AM
  2. Ext.draw.Sprite text: can't create dynamically
    By vega109 in forum Ext: Discussion
    Replies: 3
    Last Post: 12 Apr 2011, 12:59 PM
  3. Replies: 1
    Last Post: 4 Apr 2011, 3:26 PM
  4. Replies: 1
    Last Post: 18 Mar 2011, 9:35 AM