diff --git a/lib/index.d.ts b/lib/index.d.ts
index d2f97fe..826e1af 100644
--- a/lib/index.d.ts
+++ b/lib/index.d.ts
@@ -1,4 +1,4 @@
-///
+///
export * as GraphicsExtras from '@pixi/graphics-extras';
export * from './app';
export * from './core';
diff --git a/lib/index.js b/lib/index.js
index 11b75ba..7d8cfd5 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -1068,6 +1068,7 @@ class GraphicCopyPlugin {
container;
scene;
keyListeners;
+ graphicKeyListenercMap;
copys;
start;
running = false;
@@ -1075,6 +1076,7 @@ class GraphicCopyPlugin {
constructor(scene) {
this.scene = scene;
this.container = new Container();
+ this.graphicKeyListenercMap = new Map();
this.copys = [];
this.keyListeners = [];
this.keyListeners.push(new KeyListener({
@@ -1130,6 +1132,10 @@ class GraphicCopyPlugin {
this.container.addChild(clone);
clone.repaint();
});
+ const addGraphicTypeKeyListener = this.graphicKeyListenercMap.get(app.selectedGraphics[0].type);
+ if (addGraphicTypeKeyListener) {
+ this.keyListeners.push(...addGraphicTypeKeyListener);
+ }
this.scene.canvas.on('mousemove', this.onPointerMove, this);
this.scene.canvas.on('mouseup', this.onFinish, this);
this.scene.canvas.on('rightup', this.cancle, this);
@@ -1150,6 +1156,7 @@ class GraphicCopyPlugin {
this.keyListeners.forEach((kl) => {
this.scene.app.removeKeyboardListener(kl);
});
+ this.keyListeners = this.keyListeners.splice(0, 3);
}
onPointerMove(e) {
const cp = this.scene.toCanvasCoordinates(e.global);
@@ -1182,10 +1189,13 @@ class GraphicCopyPlugin {
g.position.x += this.container.position.x;
g.position.y += this.container.position.y;
});
+ this.saveCopyGraphic();
+ this.clear();
+ }
+ saveCopyGraphic() {
this.scene.app.addGraphicAndRecord(...this.copys);
this.scene.detectRelations();
this.scene.updateSelected(...this.copys);
- this.clear();
}
cancle() {
console.log('复制操作取消');
diff --git a/lib/plugins/CopyPlugin.d.ts b/lib/plugins/CopyPlugin.d.ts
index dfa51b6..c88899f 100644
--- a/lib/plugins/CopyPlugin.d.ts
+++ b/lib/plugins/CopyPlugin.d.ts
@@ -9,6 +9,7 @@ export declare class GraphicCopyPlugin {
container: Container;
scene: IGraphicScene;
keyListeners: KeyListener[];
+ graphicKeyListenercMap: Map;
copys: JlGraphic[];
start?: Point;
running: boolean;
@@ -19,5 +20,6 @@ export declare class GraphicCopyPlugin {
clear(): void;
onPointerMove(e: FederatedPointerEvent): void;
onFinish(): void;
+ saveCopyGraphic(): void;
cancle(): void;
}