The usual procedure to somehow manipulate shapes after some event has happened is well and understood:
var circle = group.createCircle({ cx: 100, cy: 300, r: 50 }).setFill("green").setStroke("pink");
circle.connect("onclick",function(e) {
circle.setFill("red");
});
Problem is, the graphic i'm working on has been converted from a SVG file into JSON and then loaded into dojox, which means i don't actually have shape objects which i can refer to by variable. So my question is, how do i retrieve shape objects from an even listener? Something like this doesn't work:
...
var group = surface.createGroup();
dojox.gfx.utils.deserialize(group, json);
dojo.connect(group.getEventSource(),"onclick",function(ev) {
ev.target.setFill('blue');
});
The event target is the actual shape node, not the object so i can't call any dojox methods like setFill()on it. I could use just ordinary SVG DOM methods, but that would break, if dojo was using a different renderer for IE for example.
So can i somehow convert that node into a shape object? I mean, if that doesn't work, what's the point of loading a graphic into dojo like I've described anyway? I feel like i'm missing something obvious here.
This works:
instead of how the docs currently suggest: using the
onmouseclickevent. Then you can access the shape object asgfxTargetproperty of the event object.