From 57ff2ffcb1556f8861b85115c0853ca43cd10d9d Mon Sep 17 00:00:00 2001 From: ananzhusen <2459622492@qq.com> Date: Thu, 24 Oct 2024 10:31:46 +0800 Subject: [PATCH] feat:autoFocus --- packages/core/src/core.ts | 14 ++++++++++++++ packages/core/src/pen/model.ts | 1 + 2 files changed, 15 insertions(+) diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 7682cc02..de36fab6 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -981,6 +981,12 @@ export class Meta2d { this.startVideo(); this.doInitJS(); this.doInitFn(); + setTimeout(()=>{ + const pen = this.store.data.pens.find((pen)=>pen.autofocus); + if(pen){ + this.focus(pen.id); + } + },100); if (this.store.data.iconUrls) { for (const item of this.store.data.iconUrls) { loadCss(item, () => { @@ -1835,6 +1841,14 @@ export class Meta2d { this.render(); } + focus(id:string){ + const pen = this.findOne(id); + if(pen){ + this.store.hover = pen; + this.store.hover.calculative.hover = true; + this.showInput(pen); + } + } /** * 删除画笔 * @param pens 需要删除的画笔们 diff --git a/packages/core/src/pen/model.ts b/packages/core/src/pen/model.ts index c520a8e4..0d97531f 100644 --- a/packages/core/src/pen/model.ts +++ b/packages/core/src/pen/model.ts @@ -304,6 +304,7 @@ export interface Pen extends Rect { animateShadowColor?: string; animateShadowBlur?: number; input?: boolean; + autofocus?: boolean; dropdownList?: Dropdown[]; dropdownBackground?: string; dropdownColor?: string;