Reputation: 9034
Just started using Bonsai JS and can't find anything in the docs so I thought I ask here. How can I set an elements class attribute so I can define some styles in CSS? Most of the styles are supported directly in Bonsai but I would also need to change the cursor type on hover over an element.
Upvotes: 0
Views: 188
Reputation: 1510
BonsaiJS doesn't let you set a "class" attribute. Instead you add a listener when the curser hovers over a DisplayObject
.
new Rect(150, 150, 150, 150).attr({
fillColor: "red"
}).addTo(stage).on("mouseover mouseout", function(e) {
this.attr({
cursor: e.type == "mouseover" ? "pointer" : "inherit"
});
});
Upvotes: 0