This functionality is all new, only present in the nightly build, and thus not documented yet.
But using the nightly build, this should work:
item.onMouseEnter = function() {
this.fillColor = 'red';
}
item.onMouseLeave = function() {
this.fillColor = 'blue';
}
Alternatively, you can also register and deregister events using the attach and detach methods:
item.attach('mouseenter', function() {
this.fillColor = 'red';
});
item.attach('mouseleave', function() {
this.fillColor = 'blue';
});
All these events are present:
onMouseEnter, onMouseLeave, onMouseOver, onClick, onDoubleClick, onMouseDrag
And their event names:
'mouseenter', 'mouseleave', 'mouseover', 'click', 'doubleclick', 'mousedrag'
I hope this helps, until we get some documentation together.
Best,
Jürg
It seems that onClick will take effect only if other mouse event is
also registered. For example:
var myCircle = new Path.Circle(new Point(100, 70), 50);
myCircle.fillColor = 'black';
myCircle.onClick = function () {
console.log('click')
}
Above code will not work, but following works:
var myCircle = new Path.Circle(new Point(100, 70), 50);
myCircle.fillColor = 'black';
myCircle.onClick = function () {
console.log('click')
}
myCircle.onMouseDrag = function () {
console.log('drag')
}
--
王欣 (Xin Wang)
blog: http://dram.me/
J
Could you please post this issue to: http://github.com/paperjs/paper.js/issues
Thanks!
greetings,
Jonathan