| Page 1 of 1 | [ 3 posts ] |
|
When creating a new graphic object, a circle for example, I can create a new one by giving the name of the object as a string in the "type" attribute, like this example from the documentation.
Code: var mygraphic = new Y.Graphic({render:"#mygraphiccontainer"}), myrect = mygraphic.addShape({ type: "rect", width: 300, height: 200, fill: { color: "#0000ff" }, stroke: { weight: 2, color: "#ff0000" }, x: 50, y: 100 }); My question is, how do I set that same thing up for my own custom shapes rather than having to specify the class name? |
|
Currently, there is not an automated way to do this. You could probably accomplish what you want by adding a key value pair to you Graphic instance's _shapeClass property.
Code: mygraphic._shapeClass.mycustomshape = Y.MyCustomShape; mygraphic.addShape({ type: "mycustomshape", ... }); Thanks, Tripp |
|
Thanks Tripp.
I was trying to instantiate a new shape based on the name of the class of the dom element the user clicked on. In the end I created a method that takes the name as a param and returns the right shape for that element. |
| Page 1 of 1 | [ 3 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group