!3018 优化:双击文字的编辑框位置和文字间距

pull/3055/MERGE
林三 4 weeks ago committed by ChenX
parent d0cc1e2b83
commit 3fbf5e2479

@ -11,6 +11,8 @@ import { CADFiler } from '../CADFiler';
import { Entity } from '../Entity/Entity';
import { FontLoader } from './FontLoader';
export const TEXT_HEIGHT_SCALE = 1.35;
export enum TextAligen
{
LeftTop = 3, Top = 1, RightTop = 5,
@ -178,7 +180,7 @@ export class Text extends Entity
else
count += 0.5;
}
return count * this._Height * 1.35;
return count * this._Height * TEXT_HEIGHT_SCALE;
}
get HasBoundingBox() { return this._CacheDrawObject.has(RenderType.Wireframe); }

@ -7,7 +7,7 @@ import { GetEntity } from '../../Common/Utils';
import { DownPanelStore } from '../../UI/Store/DownPanelStore';
import { RoomRegion } from '../Room/Entity/Region/RoomRegion';
import { FontLoader } from './FontLoader';
import { Text } from './Text';
import { TEXT_HEIGHT_SCALE, Text } from './Text';
//这是一个单例类.
export class TextArea extends Singleton
@ -84,12 +84,13 @@ export class TextArea extends Singleton
}
CreateEditorArea(position?: Vector3)
{
let height = this.TextareaHeight;
let height = this.TextareaHeight * TEXT_HEIGHT_SCALE;
let pos = this.ScreenPostion;
// 因为textarea自适应宽高比较麻烦所以用可编辑的div
let textarea = document.createElement('div');
let strs = this._CurrentValue.split("\n");
let row = strs.length;
let innnerHtml = strs.shift();
for (let s of strs)
innnerHtml += `<div>${s}</div>`;
@ -102,12 +103,12 @@ export class TextArea extends Singleton
let rect = canvasEl.getBoundingClientRect();
textarea.style.cssText = `
line-height:1;
line-height:${TEXT_HEIGHT_SCALE};
min-width:100px;
font-size:${height}px;
min-height:${height}px;
left:${position?.x ?? pos.x + rect.left}px;
top:${position?.y ?? pos.y - height + rect.top}px;
top:${position?.y ?? pos.y - height * TEXT_HEIGHT_SCALE * row + rect.top}px;
`;
this._AreaContiner.appendChild(textarea);
textarea.focus();

Loading…
Cancel
Save