event handling on shapes in dojo gfx

1.2k views Asked by At

I am creating a surface and drawing some shapes onto it. Now doing a

dojo.connect(iSurface.getEventSource(), "mousedown", HandleMouseDown);

and during handler trying to make the target shape moveable.

HandleMouseDown(event)
{
    foo = new dojox.gfx.Moveable(event.target);
}

However I keep getting "this.shape.connect is not a function", I think this is due to the fact that event.target is a svg rect not a gfx shape object. Can anyone help me in finding how do I get gfx shape object in the event instead of underlying svg object?

Thanks.

1

There are 1 answers

0
Jesus Crysist On

You can provide context as an argument to dojo.connect:

dojo.connect(iSurface.getEventSource(), 'mousedown', {shapeObj: svgShape}, HandleMouseDown);

or if shapeObj object belongs to this:

dojo.connect(iSurface.getEventSource(), 'mousedown', this, HandleMouseDown);

and have this.shapeObj in event handler:

function HandleMouseDown(e) {
  foo = new dojox.gfx.Moveable(this.shapeObj);
}