First tool on PGF
April 13th, 2007
As promised, I have adding the first tool in PGF. It’s a select/move tool. It’s easy as a pie to activate, only two lines of code. Just after renderer creation, add:
1 2 var toolManager = new Graphic.ToolManager(renderer); 3 toolManager.setTool(new Graphic.SelectTool());
I use my EventNotifier class, so you can receive an event on each move. You can play with it here
Of course, you can do it without using toolManager by observing events on DOM Element like this:1 2 Event.observe("rectangle_0", "mouseover", function() {alert("over a rectangle")});
But keep in mind it won’t work for canvas as canvas does use DOM element for rendering. But, anyway, this version of PGF doed not support selection in canvas.
A Group class has also been added to group shapes. Once grouped, you can apply transform on group, it will affect all included shapes. (Only SVG/VML, canvas renderer will do it later).
Sorry, comments are closed for this article.