OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How can I handle events, in Fabric.js, on a individual object within a group?

  • Thread starter Thread starter marshy101
  • Start date Start date
M

marshy101

Guest
Lets say i have 3 circles and add them to a group.

Code:
var circle1 = new fabric.Circle({
  radius: 50,
  fill: 'red',
  left: 0
});
var circle2 = new fabric.Circle({
  radius: 50,
  fill: 'green',
  left: 100
});
var circle3 = new fabric.Circle({
  radius: 50,
  fill: 'blue',
  left: 200
});

var group = new fabric.Group([ circle1, circle2, circle3 ], {
  left: 200,
  top: 100
});

canvas.add(group);

How can I handle mouse events for just, let's say, circle1?

Or in other words, how can I know which of the objects, in the group, the mouse clicked on?

<p>Lets say i have 3 circles and add them to a group.</p>

<pre><code>var circle1 = new fabric.Circle({
radius: 50,
fill: 'red',
left: 0
});
var circle2 = new fabric.Circle({
radius: 50,
fill: 'green',
left: 100
});
var circle3 = new fabric.Circle({
radius: 50,
fill: 'blue',
left: 200
});

var group = new fabric.Group([ circle1, circle2, circle3 ], {
left: 200,
top: 100
});

canvas.add(group);
</code></pre>

<p>How can I handle mouse events for just, let's say, circle1? </p>

<p>Or in other words, how can I know which of the objects, in the group, the mouse clicked on?</p>
 

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top