-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to identify which object is been clicked on in grab mode? #23
Comments
I think you can identify the grabbed object in Object:Selected Event |
If you wanted to do something if the active / selected object is of a specific type, you can do:
See these docs: http://fabricjs.com/docs/fabric.Canvas.html#getActiveObject |
Active Doesn't mean that the object is grabbed ? |
Actually, I thought you aren't able to click on anything in grab mode.. You're just panning around the canvas. In that case, you are right about using events. |
Anyone solved this in a nice way? |
This seems like a fabric.js question/issue more than a fabricjs-viewport issue. As @anans21 mentions getActiveObject returns the selected object but it doesn't work correctly multiple objects selected (and the fabric devs have expressed that they have no intention of fixing it IIRC.) |
You need to use getActiveGroup to get the selected objects. |
getActiveGroup works for multiple (would be nice it was available when only one was selected as well) but there is no activeObject/Group in grab mode |
You can also make an object clickable in grab mode by setting the objects' selectable property to true.
|
This is how you make objects selectable in grab mode. My above post shows how to get the selected objects, or object if only one object is selected.
Setting canvas.selection to true will enable clicking and dragging your mouse over object(s) to select them.. But my assumption is that you wouldn't want that since you're in grab mode. |
Oops. Ignore my comments I forgot grab mode was panning and not On Tue, Jun 16, 2015 at 12:41 PM, Sameer Anand [email protected]
|
In normal status, I can track the 'mouse:down' event to find out which object is been clicked. But in grab mode, all objects in canvas are not clickable. How can I know which object is being clicked in grab mode?
The text was updated successfully, but these errors were encountered: