From bae8520405f1ee745ee71ae63813b647bb585e81 Mon Sep 17 00:00:00 2001 From: AlexandreS <32449369+AlexandreSi@users.noreply.github.com> Date: Fri, 18 Feb 2022 16:06:24 +0100 Subject: [PATCH] Improve copy pasting objects on the scene - When pasting objects, the pasted objects are selected - Fix the possibility to undo/redo an object paste --- newIDE/app/src/SceneEditor/index.js | 10 +++++++--- .../KeyboardShortcuts/DeprecatedKeyboardShortcuts.js | 9 +++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/newIDE/app/src/SceneEditor/index.js b/newIDE/app/src/SceneEditor/index.js index 4524ea4e71..b87373bda3 100644 --- a/newIDE/app/src/SceneEditor/index.js +++ b/newIDE/app/src/SceneEditor/index.js @@ -887,20 +887,24 @@ export default class SceneEditor extends React.Component { const y = SafeExtractor.extractNumberProperty(clipboardContent, 'y'); if (x === null || y === null || instancesContent === null) return; - instancesContent + const newInstances = instancesContent .map(serializedInstance => { const instance = new gd.InitialInstance(); unserializeFromJSObject(instance, serializedInstance); return instance; }) - .forEach(instance => { + .map(instance => { instance.setX(instance.getX() - x + position[0]); instance.setY(instance.getY() - y + position[1]); - this.props.initialInstances + const newInstance = this.props.initialInstances .insertInitialInstance(instance) .resetPersistentUuid(); instance.delete(); + return newInstance; }); + this._onInstancesAdded(newInstances); + this.instancesSelection.clearSelection(); + this.instancesSelection.selectInstances(newInstances, true); }; updateBehaviorsSharedData = () => { diff --git a/newIDE/app/src/UI/KeyboardShortcuts/DeprecatedKeyboardShortcuts.js b/newIDE/app/src/UI/KeyboardShortcuts/DeprecatedKeyboardShortcuts.js index 370c5cb914..db6f4f91bf 100644 --- a/newIDE/app/src/UI/KeyboardShortcuts/DeprecatedKeyboardShortcuts.js +++ b/newIDE/app/src/UI/KeyboardShortcuts/DeprecatedKeyboardShortcuts.js @@ -146,10 +146,11 @@ export default class DeprecatedKeyboardShortcuts { this.onPaste(); } if (this._isControlPressed() && evt.which === Z_KEY) { - this.onUndo(); - } - if (this._isControlPressed() && this.shiftPressed && evt.which === Z_KEY) { - this.onRedo(); + if (this.shiftPressed) { + this.onRedo(); + } else { + this.onUndo(); + } } if (this._isControlPressed() && evt.which === Y_KEY) { this.onRedo();