Merge branch 'develop' of http://xny.yj-3d.com:3000/zh/sdk4.0
This commit is contained in:
@ -4,15 +4,32 @@
|
||||
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 callback=方法回调
|
||||
* @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 +41,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 +67,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 +101,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
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user