fabricjs / fabric.js

Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser
http://fabricjs.com
Other
28.93k stars 3.51k forks source link

Unable to select or move other shapes(when drawing free hand line) #6737

Closed OilPrince closed 3 years ago

OilPrince commented 3 years ago

Hello, everyone! Thank you for your efforts.

I'm trying to draw a free line on the canvas with the mouse as follows:

canvas.selection = true;

canvas.isDrawingMode = true;

canvas.freeDrawingBrush.color = 'red'; canvas.freeDrawingBrush.width = 3;

canvas.on({'path:created': (event) => { event.path.selectable = true; event.path.id = generateId('FreeLine'); canvas.setActiveObject(event.path); } });

When I try to select another drawn line after some line is drawn, the line is not selected and another line is drawn after mouse move. Of cource, I know that I can select the drawn line when I try that canvas.isDrawingMode = false; and canvas.selection = true;. But I want to continue to draw other free lines without clicking the new button that changes the draw mode(canvas.isDrawingMode = true; and canvas.selection = true;)

When I draw another shape (rectangle, circle, and straight line, ...), I check that when I move the mouse to some drawn shape, the mouse cursor changes to a movable cursor on that shape, and that shape is selected after mouse click! The selected shape has been moved or size modified by mouse control.

How can I choose a different shape and move it when I draw a free line?

I need your help.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

asturur commented 3 years ago

i'm sorry but diring freeDrawing you can't select shapes. You can try to use the event mousedown:before in order to disable the freedrawing and the reenable it on mouseup.

OilPrince commented 3 years ago

Thank you for your response. Your answer has created a way for me to do something.

There will be performance issues if there are more shapes, but it won't be a big problem to me!

Thank you for the information.

asturur commented 3 years ago

the perforance issues aren't really there, and anyway, finding the objects is quick, it can be a bit slow with 2000+ objects but being onclick and not on mouse move, i do not think you will notice it