mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
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:
@@ -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 = () => {
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user