Improve copy pasting objects on the scene

- When pasting objects, the pasted objects are selected
- Fix the possibility to undo/redo an object paste
This commit is contained in:
AlexandreS
2022-02-18 16:06:24 +01:00
committed by GitHub
parent 78559f439a
commit bae8520405
2 changed files with 12 additions and 7 deletions

View File

@@ -887,20 +887,24 @@ export default class SceneEditor extends React.Component<Props, State> {
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 = () => {

View File

@@ -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();