diff --git a/src/Obj/Base/TextBox/index.js b/src/Obj/Base/TextBox/index.js index b97613b..44ddb84 100644 --- a/src/Obj/Base/TextBox/index.js +++ b/src/Obj/Base/TextBox/index.js @@ -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 } diff --git a/src/YJEarth/index.js b/src/YJEarth/index.js index 27a1dad..0f5df67 100644 --- a/src/YJEarth/index.js +++ b/src/YJEarth/index.js @@ -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