title: copy and paste in fabric.js 2.0 beta6
body: <p>I was using this code with <code>fabric.js</code> prior to <code>2.x beta6</code> to copy and paste stuff and it was working fine:</p>
  
  <pre><code>function copy() {
      var activeObject = canvas.getActiveObject(),
          activeGroup = canvas.getActiveGroup();
  
      if (activeGroup) {
          _clipboard = activeGroup;
      } else if (activeObject) {
          _clipboard = activeObject;
      }
      return false;
  }
  
  function paste() {
      var activeObject = canvas.getActiveObject(),
          activeGroup = canvas.getActiveGroup();
      canvas.discardActiveObject();
      if (_clipboard.size) {
  
          _clipboard.clone(function (clonedObj) {
              canvas.discardActiveGroup();
              clonedObj.set({
                  left: clonedObj.left + 10,
                  top: clonedObj.top + 10,
                  evented: true
              });
  
              clonedObj.forEachObject(function (obj) {
                  obj.set('active', true);
                  canvas.add(obj);
              });
  
              canvas.setActiveGroup(clonedObj).renderAll();
          });
      } else {
          _clipboard.clone(function (clonedObj) {
              clonedObj
                  .set("top", _clipboard.top + 5)
                  .set("left", _clipboard.left + 5)
                  .setCoords();
  
              canvas
                  .add(clonedObj)
                  .setActiveObject(clonedObj)
                  .renderAll();
          });
      }
  }
  </code></pre>
  
  <p>Since in the new version the selection process has been simplified by much and some methods have been removed (see here):</p>
  
  <p><a href="http://fabricjs.com/v2-breaking-changes-2" rel="nofollow noreferrer">http://fabricjs.com/v2-breaking-changes-2</a></p>
  
  <p>Please refere to this document and generally to this link:</p>
  
  <p><a href="http://fabricjs.com/changelog" rel="nofollow noreferrer">http://fabricjs.com/changelog</a></p>
  
  <p>The above solution will not work anymore. So I was trying to adopt my script to the new beta like this:</p>
  
  <pre><code>function copy() {
      var activeObject = canvas.getActiveObject();
          _clipboard = activeObject;
         console.log(_clipboard);
  }
  
  
  function paste() {
      var activeObject = canvas.getActiveObject();
      canvas.discardActiveObject();
      if (_clipboard.size) {
  
          _clipboard.clone(function (clonedObj) {
              canvas.discardActiveObject();
              clonedObj.set({
                  left: clonedObj.left + 10,
                  top: clonedObj.top + 10,
                  evented: true,
                  active: true
              });
  
              clonedObj.forEachObject(function (obj) {
                  obj.set('active', true);
                  canvas.add(obj);
              });
  
              canvas.setActiveObject(clonedObj);
              canvas.requestRenderAll;
          });
      } else {
          _clipboard.clone(function (clonedObj) {
              canvas.discardActiveObject();
              clonedObj.set("top", _clipboard.top + 5);
              clonedObj.set("left", _clipboard.left + 5);
              clonedObj.set('active', true);
              clonedObj.setCoords();
  
  
  
              canvas.add(clonedObj);
              canvas.setActiveObject(clonedObj);
              canvas.requestRenderAll;
          });
      }
  }
  </code></pre>
  
  <p>I am facing the following problems:</p>
  
  <ol>
  <li>I am not able to copy and paste multiple selected (not grouped)
  objects</li>
  <li>Copy and paste of a grouped object work, but once the pasted object is deselected it is not selectable again.</li>
  </ol>
  
  <p>See this Fiddle: <a href="https://jsfiddle.net/sharksinn/wta4pdpz/1/" rel="nofollow noreferrer">https://jsfiddle.net/sharksinn/wta4pdpz/1/</a></p>
  
  <p>EDIT: this is the working and updated Fiddle:</p>
  
  <p><a href="https://jsfiddle.net/sharksinn/wta4pdpz/13/" rel="nofollow noreferrer">https://jsfiddle.net/sharksinn/wta4pdpz/13/</a></p>