Skip to content

Commit 724157c

Browse files
committed
fix: 防止在拖中节点的过程中按下空格键进入编辑状态
1 parent c7758d8 commit 724157c

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

app/src/core/render/canvas2d/renderer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,10 @@ export class Renderer {
686686
let x = margin;
687687
const fontSize = 30;
688688

689-
for (const key of this.project.controller.pressingKeySet) {
689+
for (let key of this.project.controller.pressingKeySet) {
690+
if (key === " ") {
691+
key = "␣";
692+
}
690693
const textLocation = new Vector(x, this.h - 100);
691694
this.project.textRenderer.renderText(
692695
key,

app/src/core/service/controlService/keyboardOnlyEngine/keyboardOnlyEngine.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { EntityShakeEffect } from "@/core/service/feedbackService/effectEngine/c
44
import { Settings } from "@/core/service/Settings";
55
import { TextNode } from "@/core/stage/stageObject/entity/TextNode";
66
import { getEnterKey } from "@/utils/keyboardFunctions";
7+
import { toast } from "sonner";
78

89
/**
910
* 纯键盘控制的相关引擎
@@ -53,8 +54,14 @@ export class KeyboardOnlyEngine {
5354
}
5455
} else if (event.key === " ") {
5556
if (Settings.textNodeStartEditMode === "space") {
57+
// 用户设置了空格键进入节点编辑状态(3群用户:神奈川)
5658
const selectedNode = this.project.stageManager.getTextNodes().find((node) => node.isSelected);
5759
if (!selectedNode) return;
60+
if (this.project.controller.isMouseDown[0]) {
61+
// 不要在可能拖动节点的情况下按空格
62+
toast.warning("请不要在拖动节点的过程中按空格");
63+
return;
64+
}
5865
startEditNode(event, selectedNode);
5966
}
6067
} else if (event.key === "Escape") {

app/src/core/service/feedbackService/effectEngine/concrete/RectangleSlideEffect.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class RectangleSlideEffect extends Effect {
1919
) {
2020
super(timeProgress);
2121
this.subEffects = [];
22-
const trailCount = 50; // 每条边显示5条尾翼线
22+
const spacing = 20; // 尾翼线之间保持固定间距
2323
const minLength = 100;
2424
const maxLength = 200;
2525

@@ -28,9 +28,9 @@ export class RectangleSlideEffect extends Effect {
2828
const isMovingRight = endRect.left > startRect.left;
2929
const edgeX = isMovingRight ? endRect.left : endRect.right;
3030

31-
// 在垂直边缘均匀分布尾翼线
32-
for (let i = 0; i < trailCount; i++) {
33-
const y = endRect.top + (endRect.height * i) / (trailCount - 1);
31+
// 在垂直边缘按固定间距分布尾翼线
32+
for (let offset = 0; offset <= endRect.height; offset += spacing) {
33+
const y = endRect.top + offset;
3434
const startPoint = new Vector(edgeX, y);
3535
const endPoint = isMovingRight
3636
? startPoint.subtract(new Vector(Random.randomFloat(minLength, maxLength), 0))
@@ -45,9 +45,9 @@ export class RectangleSlideEffect extends Effect {
4545
const isMovingDown = endRect.top > startRect.top;
4646
const edgeY = isMovingDown ? endRect.top : endRect.bottom;
4747

48-
// 在水平边缘均匀分布尾翼线
49-
for (let i = 0; i < trailCount; i++) {
50-
const x = endRect.left + (endRect.width * i) / (trailCount - 1);
48+
// 在水平边缘按固定间距分布尾翼线
49+
for (let offset = 0; offset <= endRect.width; offset += spacing) {
50+
const x = endRect.left + offset;
5151
const startPoint = new Vector(x, edgeY);
5252
const endPoint = isMovingDown
5353
? startPoint.subtract(new Vector(0, Random.randomFloat(minLength, maxLength)))

0 commit comments

Comments
 (0)