mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 17:50:42 +02:00
Create app script textareas
This commit is contained in:
parent
6bc6712ef9
commit
74e505861e
1 changed files with 52 additions and 4 deletions
|
@ -1997,14 +1997,14 @@ const GROUPS = [
|
||||||
properties: [
|
properties: [
|
||||||
{
|
{
|
||||||
label: "Script",
|
label: "Script",
|
||||||
type: "string",
|
type: "code",
|
||||||
buttons: [ { id: "reload", label: "F", className: "glyph", onClick: reloadScripts } ],
|
buttons: [ { id: "reload", label: "F", className: "glyph", onClick: reloadScripts } ],
|
||||||
propertyID: "script",
|
propertyID: "script",
|
||||||
placeholder: "URL",
|
placeholder: "URL",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Server Script",
|
label: "Server Script",
|
||||||
type: "string",
|
type: "code",
|
||||||
buttons: [ { id: "reload", label: "F", className: "glyph", onClick: reloadServerScripts } ],
|
buttons: [ { id: "reload", label: "F", className: "glyph", onClick: reloadServerScripts } ],
|
||||||
propertyID: "serverScripts",
|
propertyID: "serverScripts",
|
||||||
placeholder: "URL",
|
placeholder: "URL",
|
||||||
|
@ -2292,6 +2292,7 @@ function getPropertyInputElement(propertyID) {
|
||||||
case 'bool':
|
case 'bool':
|
||||||
case 'dropdown':
|
case 'dropdown':
|
||||||
case 'textarea':
|
case 'textarea':
|
||||||
|
case 'code':
|
||||||
case 'texture':
|
case 'texture':
|
||||||
return property.elInput;
|
return property.elInput;
|
||||||
case 'multipleZonesSelection':
|
case 'multipleZonesSelection':
|
||||||
|
@ -2450,7 +2451,8 @@ function resetProperties() {
|
||||||
setDropdownText(property.elInput);
|
setDropdownText(property.elInput);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'textarea': {
|
case 'textarea':
|
||||||
|
case 'code': {
|
||||||
property.elInput.classList.remove('multi-diff');
|
property.elInput.classList.remove('multi-diff');
|
||||||
property.elInput.value = "";
|
property.elInput.value = "";
|
||||||
setTextareaScrolling(property.elInput);
|
setTextareaScrolling(property.elInput);
|
||||||
|
@ -3428,6 +3430,47 @@ function createTextareaProperty(property, elProperty) {
|
||||||
return elInput;
|
return elInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createCodeProperty(property, elProperty) {
|
||||||
|
let elementID = property.elementID;
|
||||||
|
let propertyData = property.data;
|
||||||
|
|
||||||
|
elProperty.className = "textarea";
|
||||||
|
|
||||||
|
let elInput = document.createElement('textarea');
|
||||||
|
elInput.setAttribute("id", elementID);
|
||||||
|
if (propertyData.readOnly) {
|
||||||
|
elInput.readOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
elInput.addEventListener('change', createEmitTextPropertyUpdateFunction(property));
|
||||||
|
elInput.addEventListener('keydown', function(event) {
|
||||||
|
if (event.key === 'Tab') {
|
||||||
|
event.preventDefault();
|
||||||
|
const prevStart = this.selectionStart + 1;
|
||||||
|
this.value = this.value.substring(0, this.selectionStart)
|
||||||
|
+ "\t"
|
||||||
|
+ this.value.substring(this.selectionEnd);
|
||||||
|
this.selectionStart = prevStart;
|
||||||
|
this.selectionEnd = prevStart;
|
||||||
|
} else if (event.key === 'Escape') {
|
||||||
|
event.preventDefault();
|
||||||
|
this.blur();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let elMultiDiff = document.createElement('span');
|
||||||
|
elMultiDiff.className = "multi-diff";
|
||||||
|
|
||||||
|
elProperty.appendChild(elInput);
|
||||||
|
elProperty.appendChild(elMultiDiff);
|
||||||
|
|
||||||
|
if (propertyData.buttons !== undefined) {
|
||||||
|
addButtons(elProperty, elementID, propertyData.buttons, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return elInput;
|
||||||
|
}
|
||||||
|
|
||||||
function createIconProperty(property, elProperty) {
|
function createIconProperty(property, elProperty) {
|
||||||
let elementID = property.elementID;
|
let elementID = property.elementID;
|
||||||
|
|
||||||
|
@ -3665,6 +3708,10 @@ function createProperty(propertyData, propertyElementID, propertyName, propertyI
|
||||||
property.elInput = createTextareaProperty(property, elProperty);
|
property.elInput = createTextareaProperty(property, elProperty);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'code': {
|
||||||
|
property.elInput = createCodeProperty(property, elProperty);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'multipleZonesSelection': {
|
case 'multipleZonesSelection': {
|
||||||
property.elInput = createZonesSelection(property, elProperty);
|
property.elInput = createZonesSelection(property, elProperty);
|
||||||
break;
|
break;
|
||||||
|
@ -5476,7 +5523,8 @@ function handleEntitySelectionUpdate(selections, isPropertiesToolUpdate) {
|
||||||
setDropdownText(property.elInput);
|
setDropdownText(property.elInput);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'textarea': {
|
case 'textarea':
|
||||||
|
case 'code': {
|
||||||
property.elInput.value = propertyValue;
|
property.elInput.value = propertyValue;
|
||||||
setTextareaScrolling(property.elInput);
|
setTextareaScrolling(property.elInput);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue