Wednesday, June 5, 2024
63
rated 0 times [  70] [ 7]  / answers: 1 / hits: 34133  / 11 Years ago, sun, december 15, 2013, 12:00:00

Is there a way to explicitly select all the objects present at a particular instance of time.
This can be easily done using mouse to select all. Is there a code-solution like a button named Select All so that clicking it would make all the fabric type objects being selected and then I could apply the changes to whole of that ActiveGroup using canvas.getActiveGroup(); and iterate over.


More From » html5-canvas

 Answers
18

Good question.



There's no built-in method for this, but you would need to do something along these lines:



var objs = canvas.getObjects().map(function(o) {
return o.set('active', true);
});

var group = new fabric.Group(objs, {
originX: 'center',
originY: 'center'
});

canvas._activeObject = null;

canvas.setActiveGroup(group.setCoords()).renderAll();


The code should be self-explanatory, and it's pretty much what's happening under the hood when you use mouse, shift+click, etc.


[#73727] Thursday, December 12, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
erick

Total Points: 588
Total Questions: 92
Total Answers: 100

Location: Bangladesh
Member since Sat, Jan 23, 2021
3 Years ago
erick questions
;