Thank you for your link, this was the solution :) but i never succed to use the restoreObjectsState() function.... Actually i wanted users to be able to change IText of a group directly on the canvas and not programatically.
After a click on a group (on mouse:up) i ungroup the group then the user can change the IText when the user want to move the group or do somthing else with aonther group i regroup the group
here i tried to give a quite simple example of what i did :
gbbUngroup = false;
gbbOnMove = false;
gbbIsDown = false;
var iGaucheGroupe;
var iHautGroupe;
canvas.on('mouse:up', function(oCursor){
gbbIsDown = false;
if ((oCurseur.target.type == 'group') && (gbbOnMove == false)){
//ungroup the group to modify the IText
ungroup();
gbbUngroup = true;
} else {
gbbOnMove = false;
}
});
canvas.on('mouse:down', function(oCursor){
gbbIsDown = true;
});
canvas.on('mouse:move', function(oCursor){
if ((gbbUngroup == true) && (gbbIsDown)) { //(you can add other conditions)
//group the objects
group();
gbbOnMove = true;
}
});
function ungroup(){
var fabGroupeSelectionne = canvas.getActiveObject();
var i=0;
var lItems = fabGroupeSelectionne._objects;
//I keep the coordinates of my group (my objects are at the top anf left of the group)
iGaucheGroupe = fabGroupeSelectionne.getLeft();
iHautGroupe = fabGroupeSelectionne.getTop();
//I delete the group
canvas.remove(fabGroupeSelectionne);
while (i < fabGroupeSelectionne.size()) {
//I create separatly the objects of the group
lItems[i].set({left : iGaucheGroupe, top : iHautGroupe, selectable : true});
canvas.add(lItems[i]);
i++;
}
canvas.renderAll();
}
function group(){
var fabReGroup = new fabric.Group([
canvas.item(canvas.size()-2).clone(),
canvas.item(canvas.size()-1).clone()
]);
fabReGroup.set({left: iGaucheGroupe, top : iHautGroupe});
canvas.item(canvas.size()-2).remove();
canvas.item(canvas.size()-1).remove();
canvas.add(fabReGroup);
}