From a17dc4171a49e39537dbd293155fd32527fc4025 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Tue, 21 Jun 2011 01:52:44 +0200 Subject: [PATCH] Fix bug where cloned items that were selected weren't appearing in the Project#selectedItems array. --- src/item/Item.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 4cffc724..6f1b65ce 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -580,14 +580,15 @@ var Item = this.Item = Base.extend({ // TODO: Consider moving this to Base once it's useful in more than one // place var keys = ['_locked', '_visible', '_opacity', '_blendMode', - '_clipMask', '_selected']; + '_clipMask']; for (var i = 0, l = keys.length; i < l; i++) { var key = keys[i]; if (this.hasOwnProperty(key)) copy[key] = this[key]; } - // Insert the clone above the original, at the same position. - copy.insertAbove(this); + // Copy over the selection state, use setSelected so the item + // is also added to Project#selectedItems if it is selected. + copy.setSelected(this._selected); // Only set name once the copy is moved, to avoid setting and unsettting // name related structures. if (this._name)