修改文本框的传入和回调

This commit is contained in:
2025-08-19 13:58:12 +08:00
parent 25a7c967bb
commit 3358221da9
2 changed files with 26 additions and 2 deletions

View File

@ -4,15 +4,31 @@
import Base from "../index";
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
class TextBox extends Base {
constructor(sdk, options = {}) {
/**
* @constructor
* @param sdk
* @description 文本框
* @param options {object} 属性
* @param options.id=id
* @param options.positions=[]位置
* @param options.text=文本框内容
* @param options.show=true {boolean}是否显示
* @param Dialog {object} 弹框对象
* @param Dialog.confirmCallBack {function} 弹框确认时的回调
* */
constructor(sdk, options = {}, callback = null) {
// this.sdk = { ...sdk }
// this.options = { ...options }
super(sdk, options)
this.options.positions = options.positions || []
this.options.text = options.text || ''
this.options.show = (options.show || options.show === false) ? options.show : true
this.clickTextDom = undefined
this.handler = undefined
this.textDom = undefined
this.create(this)
this.sdk.addIncetance(this.options.id, this)
this.callback = callback
}
async create(that) {
@ -24,11 +40,13 @@ class TextBox extends Base {
// 创建textarea元素
var textarea = document.createElement('textarea');
textarea.className = 'textarea'
textarea.value = that.options.text;
// 设置textarea的属性例如行数和列数
textarea.rows = 6;
textarea.style.resize = 'none'
// 将textarea添加到div中
dom.appendChild(textarea);
(!that.options.show) && (dom.style.display = 'none')
// 将div添加到body中
// document.body.appendChild(dom);
@ -48,7 +66,8 @@ class TextBox extends Base {
}
}
viewer.scene.postRender.addEventListener(that.handler);
that.textDom = dom
that.textDom = dom;
}
async setHandeler(data) {
let that = this
@ -81,6 +100,10 @@ class TextBox extends Base {
that.sdk.viewer.scene.postRender.addEventListener(that.handler);
}
}
async getwords(words) {
this.options.text = words
this.callback(this.options)
}
async returnFun() {
return this.handler
}

View File

@ -485,6 +485,7 @@ class YJEarth {
_this.clickTextDom.removeEventListener('mousedown', mousedown);
document.removeEventListener('mousemove', mousemove);
document.removeEventListener('mouseup', mouseup);
_this.entityMap.get(_this.clickTextDom.id).getwords(_this.clickTextDom.getElementsByTagName('textarea')[0].value)
_this.clickTextDom.style['pointer-events'] = 'none'
_this.clickTextDom = undefined