Reputation: 1863
I am working on a wireframe kind of project and I am using dojo gfx to create shapes. As of now, this is where I am stuck. I am creating a gfx group (after creating a surface) and add 2 small circles (like a point) to the group. The group is a gfx.Movable one.
Now, I have 2 challenges:
1) How do I connect to the "onMoved" event of the gfx group when the group is dragged & moved? 2) How do I access the circles inside the gfx group to get its shape? Is there way I can set an Id for the group and access it like dom.byId() ? Or any alternatives/workarounds?
I thought someone would have come across a similar situation and thought I might get some help here.
Thanks.
Here is the sample code, you can assume I have required all the necessary modules and necessary HTML elements are available.
var container = dojo.byId("devicesTarget");
var surface = dojox.gfx.createSurface(container, 800, 400);
var group = surface.createGroup();
var _m1 = new gfxMoveable(group);
var circle1 = surface.createCircle({cx: 100, cy: 100, r: 3}).setStroke("green").setFill("white");
var circle2 = surface.createCircle({cx: 400, cy: 400, r: 3}).setStroke("red").setFill("white");
group.add(circle1);
group.add(circle2);
dojo.connect(_m1, "onMoved", function(ARG1){
//This code never gets executed!
console.log("ABC Hurray: The group was moved");
});
dojo.connect(group.getEventSource(), "onMoved", function(ARG1){
//This code never gets executed either!
console.log("XYZ Hurray: The group was moved");
});
dojo.connect(group.getEventSource(), "onmousemove", function(ARG1) {
//This code gets executed successfully after the entire group is moved and onmousemove is triggered. However, I am not getting the recent shape of the circles.
//I always get the initial shape of the circles! :(
var circShape1 = circle1.getShape();
var circShape2 = circle2.getShape();
console.log("circShape1 :", circShape1);
console.log("circShape2 :", circShape2);
});
Upvotes: 0
Views: 70