@babylonjs/gui 5.21.0 → 5.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2D/adtInstrumentation.js +70 -90
- package/2D/adtInstrumentation.js.map +1 -1
- package/2D/advancedDynamicTexture.d.ts +12 -0
- package/2D/advancedDynamicTexture.js +569 -622
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/button.js +76 -90
- package/2D/controls/button.js.map +1 -1
- package/2D/controls/checkbox.js +86 -106
- package/2D/controls/checkbox.js.map +1 -1
- package/2D/controls/colorpicker.js +395 -415
- package/2D/controls/colorpicker.js.map +1 -1
- package/2D/controls/container.js +187 -230
- package/2D/controls/container.js.map +1 -1
- package/2D/controls/control.js +1067 -1353
- package/2D/controls/control.js.map +1 -1
- package/2D/controls/displayGrid.js +152 -196
- package/2D/controls/displayGrid.js.map +1 -1
- package/2D/controls/ellipse.js +32 -40
- package/2D/controls/ellipse.js.map +1 -1
- package/2D/controls/focusableButton.js +30 -35
- package/2D/controls/focusableButton.js.map +1 -1
- package/2D/controls/grid.js +172 -212
- package/2D/controls/grid.js.map +1 -1
- package/2D/controls/image.js +489 -592
- package/2D/controls/image.js.map +1 -1
- package/2D/controls/inputPassword.js +9 -16
- package/2D/controls/inputPassword.js.map +1 -1
- package/2D/controls/inputText.js +380 -467
- package/2D/controls/inputText.js.map +1 -1
- package/2D/controls/inputTextArea.js +234 -273
- package/2D/controls/inputTextArea.js.map +1 -1
- package/2D/controls/line.js +147 -198
- package/2D/controls/line.js.map +1 -1
- package/2D/controls/multiLine.js +87 -113
- package/2D/controls/multiLine.js.map +1 -1
- package/2D/controls/radioButton.js +106 -127
- package/2D/controls/radioButton.js.map +1 -1
- package/2D/controls/rectangle.js +60 -72
- package/2D/controls/rectangle.js.map +1 -1
- package/2D/controls/scrollViewers/scrollViewer.js +439 -543
- package/2D/controls/scrollViewers/scrollViewer.js.map +1 -1
- package/2D/controls/scrollViewers/scrollViewerWindow.js +99 -118
- package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -1
- package/2D/controls/selector.js +241 -329
- package/2D/controls/selector.js.map +1 -1
- package/2D/controls/sliders/baseSlider.js +182 -230
- package/2D/controls/sliders/baseSlider.js.map +1 -1
- package/2D/controls/sliders/imageBasedSlider.js +86 -109
- package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
- package/2D/controls/sliders/imageScrollBar.js +148 -178
- package/2D/controls/sliders/imageScrollBar.js.map +1 -1
- package/2D/controls/sliders/scrollBar.js +64 -80
- package/2D/controls/sliders/scrollBar.js.map +1 -1
- package/2D/controls/sliders/slider.js +91 -115
- package/2D/controls/sliders/slider.js.map +1 -1
- package/2D/controls/stackPanel.js +114 -135
- package/2D/controls/stackPanel.js.map +1 -1
- package/2D/controls/statics.js +5 -5
- package/2D/controls/statics.js.map +1 -1
- package/2D/controls/textBlock.js +322 -384
- package/2D/controls/textBlock.js.map +1 -1
- package/2D/controls/textWrapper.js +27 -41
- package/2D/controls/textWrapper.js.map +1 -1
- package/2D/controls/toggleButton.js +105 -121
- package/2D/controls/toggleButton.js.map +1 -1
- package/2D/controls/virtualKeyboard.js +101 -123
- package/2D/controls/virtualKeyboard.js.map +1 -1
- package/2D/math2D.js +62 -70
- package/2D/math2D.js.map +1 -1
- package/2D/measure.js +30 -32
- package/2D/measure.js.map +1 -1
- package/2D/multiLinePoint.js +71 -89
- package/2D/multiLinePoint.js.map +1 -1
- package/2D/style.js +55 -73
- package/2D/style.js.map +1 -1
- package/2D/valueAndUnit.js +71 -104
- package/2D/valueAndUnit.js.map +1 -1
- package/2D/xmlLoader.js +70 -84
- package/2D/xmlLoader.js.map +1 -1
- package/3D/behaviors/defaultBehavior.js +40 -59
- package/3D/behaviors/defaultBehavior.js.map +1 -1
- package/3D/controls/abstractButton3D.js +8 -12
- package/3D/controls/abstractButton3D.js.map +1 -1
- package/3D/controls/button3D.js +30 -35
- package/3D/controls/button3D.js.map +1 -1
- package/3D/controls/container3D.js +57 -71
- package/3D/controls/container3D.js.map +1 -1
- package/3D/controls/contentDisplay3D.js +47 -60
- package/3D/controls/contentDisplay3D.js.map +1 -1
- package/3D/controls/control3D.js +123 -158
- package/3D/controls/control3D.js.map +1 -1
- package/3D/controls/cylinderPanel.js +28 -38
- package/3D/controls/cylinderPanel.js.map +1 -1
- package/3D/controls/handMenu.js +20 -29
- package/3D/controls/handMenu.js.map +1 -1
- package/3D/controls/holographicBackplate.js +52 -72
- package/3D/controls/holographicBackplate.js.map +1 -1
- package/3D/controls/holographicButton.js +160 -200
- package/3D/controls/holographicButton.js.map +1 -1
- package/3D/controls/holographicSlate.js +176 -206
- package/3D/controls/holographicSlate.js.map +1 -1
- package/3D/controls/meshButton3D.js +24 -30
- package/3D/controls/meshButton3D.js.map +1 -1
- package/3D/controls/nearMenu.js +57 -71
- package/3D/controls/nearMenu.js.map +1 -1
- package/3D/controls/planePanel.js +6 -13
- package/3D/controls/planePanel.js.map +1 -1
- package/3D/controls/scatterPanel.js +43 -54
- package/3D/controls/scatterPanel.js.map +1 -1
- package/3D/controls/slider3D.js +168 -222
- package/3D/controls/slider3D.js.map +1 -1
- package/3D/controls/spherePanel.js +29 -39
- package/3D/controls/spherePanel.js.map +1 -1
- package/3D/controls/stackPanel3D.js +36 -49
- package/3D/controls/stackPanel3D.js.map +1 -1
- package/3D/controls/touchButton3D.js +126 -154
- package/3D/controls/touchButton3D.js.map +1 -1
- package/3D/controls/touchHolographicButton.js +223 -272
- package/3D/controls/touchHolographicButton.js.map +1 -1
- package/3D/controls/touchHolographicMenu.js +55 -66
- package/3D/controls/touchHolographicMenu.js.map +1 -1
- package/3D/controls/touchMeshButton3D.js +24 -30
- package/3D/controls/touchMeshButton3D.js.map +1 -1
- package/3D/controls/volumeBasedPanel.js +85 -107
- package/3D/controls/volumeBasedPanel.js.map +1 -1
- package/3D/gizmos/gizmoHandle.js +68 -103
- package/3D/gizmos/gizmoHandle.js.map +1 -1
- package/3D/gizmos/slateGizmo.js +165 -182
- package/3D/gizmos/slateGizmo.js.map +1 -1
- package/3D/gui3DManager.js +76 -101
- package/3D/gui3DManager.js.map +1 -1
- package/3D/materials/fluent/fluentMaterial.js +110 -119
- package/3D/materials/fluent/fluentMaterial.js.map +1 -1
- package/3D/materials/fluent/shaders/fluent.fragment.js +20 -3
- package/3D/materials/fluent/shaders/fluent.fragment.js.map +1 -1
- package/3D/materials/fluent/shaders/fluent.vertex.js +11 -3
- package/3D/materials/fluent/shaders/fluent.vertex.js.map +1 -1
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +168 -177
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -1
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js +9 -3
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js.map +1 -1
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js +15 -3
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js.map +1 -1
- package/3D/materials/fluentButton/fluentButtonMaterial.js +205 -213
- package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -1
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.js +6 -3
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.js.map +1 -1
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.js +6 -3
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.js.map +1 -1
- package/3D/materials/handle/handleMaterial.js +56 -69
- package/3D/materials/handle/handleMaterial.js.map +1 -1
- package/3D/materials/handle/shaders/handle.fragment.js +3 -3
- package/3D/materials/handle/shaders/handle.fragment.js.map +1 -1
- package/3D/materials/handle/shaders/handle.vertex.js +3 -3
- package/3D/materials/handle/shaders/handle.vertex.js.map +1 -1
- package/3D/materials/mrdl/mrdlBackplateMaterial.js +158 -166
- package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -1
- package/3D/materials/mrdl/mrdlSliderBarMaterial.js +322 -330
- package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -1
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +322 -330
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js +9 -3
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js +6 -3
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js +24 -3
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js +12 -3
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js +24 -3
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js +12 -3
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js.map +1 -1
- package/3D/vector3WithInfo.js +6 -12
- package/3D/vector3WithInfo.js.map +1 -1
- package/legacy/legacy.js +1 -1
- package/legacy/legacy.js.map +1 -1
- package/package.json +3 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate
|
|
1
|
+
import { __decorate } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
3
3
|
import { Control } from "./control.js";
|
|
4
4
|
import { ValueAndUnit } from "../valueAndUnit.js";
|
|
@@ -8,148 +8,121 @@ import { serialize } from "@babylonjs/core/Misc/decorators.js";
|
|
|
8
8
|
/**
|
|
9
9
|
* Class used to create input text control
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
__extends(InputTextArea, _super);
|
|
11
|
+
export class InputTextArea extends InputText {
|
|
13
12
|
/**
|
|
14
13
|
* Creates a new InputTextArea
|
|
15
14
|
* @param name defines the control name
|
|
16
15
|
* @param text defines the text of the control
|
|
17
16
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_this._maxHeight = new ValueAndUnit(1, ValueAndUnit.UNITMODE_PERCENTAGE, false);
|
|
17
|
+
constructor(name, text = "") {
|
|
18
|
+
super(name);
|
|
19
|
+
this.name = name;
|
|
20
|
+
this._textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
|
|
21
|
+
this._textVerticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
|
|
22
|
+
this._lineSpacing = new ValueAndUnit(0);
|
|
23
|
+
this._outlineWidth = 0;
|
|
24
|
+
this._outlineColor = "white";
|
|
25
|
+
this._maxHeight = new ValueAndUnit(1, ValueAndUnit.UNITMODE_PERCENTAGE, false);
|
|
28
26
|
/**
|
|
29
27
|
* An event triggered after the text was broken up into lines
|
|
30
28
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
this.onLinesReadyObservable = new Observable();
|
|
30
|
+
this.text = text;
|
|
31
|
+
this.isPointerBlocker = true;
|
|
32
|
+
this.onLinesReadyObservable.add(() => this._updateCursorPosition());
|
|
33
|
+
this._highlightCursorInfo = {
|
|
36
34
|
initialStartIndex: -1,
|
|
37
35
|
initialRelativeStartIndex: -1,
|
|
38
36
|
initialLineIndex: -1,
|
|
39
37
|
};
|
|
40
|
-
|
|
38
|
+
this._cursorInfo = {
|
|
41
39
|
globalStartIndex: 0,
|
|
42
40
|
globalEndIndex: 0,
|
|
43
41
|
relativeEndIndex: 0,
|
|
44
42
|
relativeStartIndex: 0,
|
|
45
43
|
currentLineIndex: 0,
|
|
46
44
|
};
|
|
47
|
-
return _this;
|
|
48
45
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Gets or sets outlineWidth of the text to display
|
|
48
|
+
*/
|
|
49
|
+
get outlineWidth() {
|
|
50
|
+
return this._outlineWidth;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets or sets outlineWidth of the text to display
|
|
54
|
+
*/
|
|
55
|
+
set outlineWidth(value) {
|
|
56
|
+
if (this._outlineWidth === value) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this._outlineWidth = value;
|
|
60
|
+
this._markAsDirty();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Gets or sets outlineColor of the text to display
|
|
64
|
+
*/
|
|
65
|
+
get outlineColor() {
|
|
66
|
+
return this._outlineColor;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets or sets outlineColor of the text to display
|
|
70
|
+
*/
|
|
71
|
+
set outlineColor(value) {
|
|
72
|
+
if (this._outlineColor === value) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this._outlineColor = value;
|
|
76
|
+
this._markAsDirty();
|
|
77
|
+
}
|
|
78
|
+
/** Gets or sets a boolean indicating if the control can auto stretch its height to adapt to the text */
|
|
79
|
+
get autoStretchHeight() {
|
|
80
|
+
return this._autoStretchHeight;
|
|
81
|
+
}
|
|
82
|
+
set autoStretchHeight(value) {
|
|
83
|
+
if (this._autoStretchHeight === value) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this._autoStretchHeight = value;
|
|
87
|
+
this._markAsDirty();
|
|
88
|
+
}
|
|
89
|
+
set height(value) {
|
|
90
|
+
this._fixedRatioMasterIsWidth = false;
|
|
91
|
+
if (this._height.toString(this._host) === value) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (this._height.fromString(value)) {
|
|
84
95
|
this._markAsDirty();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
}
|
|
97
|
+
this._autoStretchHeight = false;
|
|
98
|
+
}
|
|
99
|
+
get maxHeight() {
|
|
100
|
+
return this._maxHeight.toString(this._host);
|
|
101
|
+
}
|
|
102
|
+
/** Gets the maximum width allowed by the control in pixels */
|
|
103
|
+
get maxHeightInPixels() {
|
|
104
|
+
return this._maxHeight.getValueInPixel(this._host, this._cachedParentMeasure.height);
|
|
105
|
+
}
|
|
106
|
+
set maxHeight(value) {
|
|
107
|
+
if (this._maxHeight.toString(this._host) === value) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (this._maxHeight.fromString(value)) {
|
|
99
111
|
this._markAsDirty();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(InputTextArea.prototype, "height", {
|
|
105
|
-
set: function (value) {
|
|
106
|
-
this._fixedRatioMasterIsWidth = false;
|
|
107
|
-
if (this._height.toString(this._host) === value) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (this._height.fromString(value)) {
|
|
111
|
-
this._markAsDirty();
|
|
112
|
-
}
|
|
113
|
-
this._autoStretchHeight = false;
|
|
114
|
-
},
|
|
115
|
-
enumerable: false,
|
|
116
|
-
configurable: true
|
|
117
|
-
});
|
|
118
|
-
Object.defineProperty(InputTextArea.prototype, "maxHeight", {
|
|
119
|
-
get: function () {
|
|
120
|
-
return this._maxHeight.toString(this._host);
|
|
121
|
-
},
|
|
122
|
-
set: function (value) {
|
|
123
|
-
if (this._maxHeight.toString(this._host) === value) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (this._maxHeight.fromString(value)) {
|
|
127
|
-
this._markAsDirty();
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
enumerable: false,
|
|
131
|
-
configurable: true
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(InputTextArea.prototype, "maxHeightInPixels", {
|
|
134
|
-
/** Gets the maximum width allowed by the control in pixels */
|
|
135
|
-
get: function () {
|
|
136
|
-
return this._maxHeight.getValueInPixel(this._host, this._cachedParentMeasure.height);
|
|
137
|
-
},
|
|
138
|
-
enumerable: false,
|
|
139
|
-
configurable: true
|
|
140
|
-
});
|
|
141
|
-
InputTextArea.prototype._getTypeName = function () {
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
_getTypeName() {
|
|
142
115
|
return "InputTextArea";
|
|
143
|
-
}
|
|
116
|
+
}
|
|
144
117
|
/**
|
|
145
118
|
* Handles the keyboard event
|
|
146
119
|
* @param evt Defines the KeyboardEvent
|
|
147
120
|
*/
|
|
148
|
-
|
|
121
|
+
processKeyboard(evt) {
|
|
149
122
|
// process pressed key
|
|
150
123
|
this.alternativeProcessKey(evt.code, evt.key, evt);
|
|
151
124
|
this.onKeyboardEventProcessedObservable.notifyObservers(evt);
|
|
152
|
-
}
|
|
125
|
+
}
|
|
153
126
|
/**
|
|
154
127
|
* Process the last keyboard input
|
|
155
128
|
*
|
|
@@ -158,7 +131,7 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
158
131
|
* @param evt The keyboard event emits with input
|
|
159
132
|
* @hidden
|
|
160
133
|
*/
|
|
161
|
-
|
|
134
|
+
alternativeProcessKey(code, key, evt) {
|
|
162
135
|
//return if clipboard event keys (i.e -ctr/cmd + c,v,x)
|
|
163
136
|
if (evt && (evt.ctrlKey || evt.metaKey) && (code === "KeyC" || code === "KeyV" || code === "KeyX")) {
|
|
164
137
|
return;
|
|
@@ -274,7 +247,7 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
274
247
|
if (evt && evt.shiftKey) {
|
|
275
248
|
// shift + ctrl/cmd + ->
|
|
276
249
|
if (evt.ctrlKey || evt.metaKey) {
|
|
277
|
-
|
|
250
|
+
const rightDelta = this._lines[this._cursorInfo.currentLineIndex].text.length - this._cursorInfo.relativeEndIndex - 1;
|
|
278
251
|
this._cursorInfo.globalEndIndex += rightDelta;
|
|
279
252
|
this._cursorInfo.globalStartIndex = this._highlightCursorInfo.initialStartIndex;
|
|
280
253
|
}
|
|
@@ -304,7 +277,7 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
304
277
|
}
|
|
305
278
|
else if (evt && (evt.ctrlKey || evt.metaKey)) {
|
|
306
279
|
//ctr + ->
|
|
307
|
-
|
|
280
|
+
const rightDelta = this._lines[this._cursorInfo.currentLineIndex].text.length - this._cursorInfo.relativeEndIndex;
|
|
308
281
|
this._cursorInfo.globalStartIndex += rightDelta;
|
|
309
282
|
}
|
|
310
283
|
else if (this._cursorInfo.globalStartIndex < this.text.length) {
|
|
@@ -337,10 +310,10 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
337
310
|
this._cursorInfo.globalStartIndex = 0;
|
|
338
311
|
}
|
|
339
312
|
else {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
313
|
+
const currentLine = this._lines[this._cursorInfo.currentLineIndex];
|
|
314
|
+
const upperLine = this._lines[this._cursorInfo.currentLineIndex - 1];
|
|
315
|
+
let tmpIndex = 0;
|
|
316
|
+
let relativeIndex = 0;
|
|
344
317
|
if (!this._isTextHighlightOn || this._cursorInfo.currentLineIndex < this._highlightCursorInfo.initialLineIndex) {
|
|
345
318
|
tmpIndex = this._cursorInfo.globalStartIndex;
|
|
346
319
|
relativeIndex = this._cursorInfo.relativeStartIndex;
|
|
@@ -349,13 +322,13 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
349
322
|
tmpIndex = this._cursorInfo.globalEndIndex;
|
|
350
323
|
relativeIndex = this._cursorInfo.relativeEndIndex;
|
|
351
324
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
325
|
+
const currentText = currentLine.text.substr(0, relativeIndex);
|
|
326
|
+
const currentWidth = this._contextForBreakLines.measureText(currentText).width;
|
|
327
|
+
let upperWidth = 0;
|
|
328
|
+
let previousWidth = 0;
|
|
356
329
|
tmpIndex -= relativeIndex; // Start of current line
|
|
357
330
|
tmpIndex -= upperLine.text.length + upperLine.lineEnding.length; // Start of upper line
|
|
358
|
-
|
|
331
|
+
let upperLineRelativeIndex = 0;
|
|
359
332
|
while (upperWidth < currentWidth && upperLineRelativeIndex < upperLine.text.length) {
|
|
360
333
|
tmpIndex++;
|
|
361
334
|
upperLineRelativeIndex++;
|
|
@@ -403,10 +376,10 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
403
376
|
this._cursorInfo.globalStartIndex = this.text.length;
|
|
404
377
|
}
|
|
405
378
|
else {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
379
|
+
const currentLine = this._lines[this._cursorInfo.currentLineIndex];
|
|
380
|
+
const underLine = this._lines[this._cursorInfo.currentLineIndex + 1];
|
|
381
|
+
let tmpIndex = 0;
|
|
382
|
+
let relativeIndex = 0;
|
|
410
383
|
if (!this._isTextHighlightOn || this._cursorInfo.currentLineIndex < this._highlightCursorInfo.initialLineIndex) {
|
|
411
384
|
tmpIndex = this._cursorInfo.globalStartIndex;
|
|
412
385
|
relativeIndex = this._cursorInfo.relativeStartIndex;
|
|
@@ -415,12 +388,12 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
415
388
|
tmpIndex = this._cursorInfo.globalEndIndex;
|
|
416
389
|
relativeIndex = this._cursorInfo.relativeEndIndex;
|
|
417
390
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
391
|
+
const currentText = currentLine.text.substr(0, relativeIndex);
|
|
392
|
+
const currentWidth = this._contextForBreakLines.measureText(currentText).width;
|
|
393
|
+
let underWidth = 0;
|
|
394
|
+
let previousWidth = 0;
|
|
422
395
|
tmpIndex += currentLine.text.length - relativeIndex + currentLine.lineEnding.length; // Start of current line
|
|
423
|
-
|
|
396
|
+
let underLineRelativeIndex = 0;
|
|
424
397
|
while (underWidth < currentWidth && underLineRelativeIndex < underLine.text.length) {
|
|
425
398
|
tmpIndex++;
|
|
426
399
|
underLineRelativeIndex++;
|
|
@@ -451,8 +424,8 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
451
424
|
return;
|
|
452
425
|
}
|
|
453
426
|
// Printable characters
|
|
454
|
-
if (
|
|
455
|
-
evt
|
|
427
|
+
if (key?.length === 1) {
|
|
428
|
+
evt?.preventDefault();
|
|
456
429
|
this._currentKey = key;
|
|
457
430
|
this.onBeforeKeyAddObservable.notifyObservers(this);
|
|
458
431
|
key = this._currentKey;
|
|
@@ -465,16 +438,15 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
465
438
|
this._textHasChanged();
|
|
466
439
|
}
|
|
467
440
|
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
var testWidth = metrics.width;
|
|
441
|
+
}
|
|
442
|
+
_parseLineWordWrap(line = "", width, context) {
|
|
443
|
+
const lines = [];
|
|
444
|
+
const words = line.split(" ");
|
|
445
|
+
let lineWidth = 0;
|
|
446
|
+
for (let n = 0; n < words.length; n++) {
|
|
447
|
+
const testLine = n > 0 ? line + " " + words[n] : words[0];
|
|
448
|
+
const metrics = context.measureText(testLine);
|
|
449
|
+
const testWidth = metrics.width;
|
|
478
450
|
if (testWidth > width) {
|
|
479
451
|
if (n > 0) {
|
|
480
452
|
// Avoid first word duplication if of too long
|
|
@@ -482,15 +454,15 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
482
454
|
lines.push({ text: line, width: lineWidth, lineEnding: " " });
|
|
483
455
|
}
|
|
484
456
|
line = words[n];
|
|
485
|
-
|
|
486
|
-
line.split("").map(
|
|
487
|
-
if (context.measureText(
|
|
488
|
-
lines.push({ text:
|
|
489
|
-
|
|
457
|
+
let flushedLine = "";
|
|
458
|
+
line.split("").map((char) => {
|
|
459
|
+
if (context.measureText(flushedLine + char).width > width) {
|
|
460
|
+
lines.push({ text: flushedLine, width: context.measureText(flushedLine).width, lineEnding: "\n" });
|
|
461
|
+
flushedLine = "";
|
|
490
462
|
}
|
|
491
|
-
|
|
463
|
+
flushedLine += char;
|
|
492
464
|
});
|
|
493
|
-
line =
|
|
465
|
+
line = flushedLine;
|
|
494
466
|
// Measure remaining characters
|
|
495
467
|
lineWidth = context.measureText(line).width;
|
|
496
468
|
}
|
|
@@ -498,35 +470,29 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
498
470
|
lineWidth = testWidth;
|
|
499
471
|
line = testLine;
|
|
500
472
|
}
|
|
501
|
-
};
|
|
502
|
-
for (var n = 0; n < words.length; n++) {
|
|
503
|
-
_loop_1(n);
|
|
504
473
|
}
|
|
505
474
|
lines.push({ text: line, width: lineWidth, lineEnding: " " });
|
|
506
475
|
return lines;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
476
|
+
}
|
|
477
|
+
_breakLines(refWidth, context) {
|
|
478
|
+
const lines = [];
|
|
479
|
+
const _lines = this.text.split("\n");
|
|
511
480
|
if (this.clipContent) {
|
|
512
|
-
for (
|
|
513
|
-
|
|
514
|
-
lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
|
|
481
|
+
for (const _line of _lines) {
|
|
482
|
+
lines.push(...this._parseLineWordWrap(_line, refWidth, context));
|
|
515
483
|
}
|
|
516
484
|
}
|
|
517
485
|
else {
|
|
518
|
-
for (
|
|
519
|
-
var _line = _lines_2[_a];
|
|
486
|
+
for (const _line of _lines) {
|
|
520
487
|
lines.push(this._parseLine(_line, context));
|
|
521
488
|
}
|
|
522
489
|
}
|
|
523
490
|
lines[lines.length - 1].lineEnding = "\n";
|
|
524
491
|
return lines;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
if (line === void 0) { line = ""; }
|
|
492
|
+
}
|
|
493
|
+
_parseLine(line = "", context) {
|
|
528
494
|
return { text: line, width: context.measureText(line).width, lineEnding: " " };
|
|
529
|
-
}
|
|
495
|
+
}
|
|
530
496
|
/**
|
|
531
497
|
* Processing of child right before the parent measurement update
|
|
532
498
|
*
|
|
@@ -534,11 +500,11 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
534
500
|
* @param context The rendering canvas
|
|
535
501
|
* @hidden
|
|
536
502
|
*/
|
|
537
|
-
|
|
503
|
+
_preMeasure(parentMeasure, context) {
|
|
538
504
|
if (!this._fontOffset || this._wasDirty) {
|
|
539
505
|
this._fontOffset = Control._GetFontOffset(context.font);
|
|
540
506
|
}
|
|
541
|
-
|
|
507
|
+
let text = this._beforeRenderText(this._textWrapper).text;
|
|
542
508
|
// placeholder conditions and color setting
|
|
543
509
|
if (!this._isFocused && !this.text && this._placeholderText) {
|
|
544
510
|
text = this._placeholderText;
|
|
@@ -549,15 +515,15 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
549
515
|
// measures the textlength -> this.measure.width
|
|
550
516
|
this._textWidth = context.measureText(text).width;
|
|
551
517
|
// we double up the margin width
|
|
552
|
-
|
|
518
|
+
const marginWidth = this._margin.getValueInPixel(this._host, parentMeasure.width) * 2;
|
|
553
519
|
if (this._autoStretchWidth) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
520
|
+
const tmpLines = text.split("\n");
|
|
521
|
+
const longerString = tmpLines.reduce((acc, val) => {
|
|
522
|
+
const valueLength = context.measureText(val).width;
|
|
523
|
+
const accLength = context.measureText(acc).width;
|
|
558
524
|
return valueLength > accLength ? val : acc;
|
|
559
525
|
}, "");
|
|
560
|
-
|
|
526
|
+
const longerStringWidth = context.measureText(longerString).width;
|
|
561
527
|
this.width = Math.min(this._maxWidth.getValueInPixel(this._host, parentMeasure.width), longerStringWidth + marginWidth) + "px";
|
|
562
528
|
this.autoStretchWidth = true;
|
|
563
529
|
}
|
|
@@ -567,16 +533,16 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
567
533
|
// can we find a cleaner implementation here?
|
|
568
534
|
this._contextForBreakLines = context;
|
|
569
535
|
if (this._autoStretchHeight) {
|
|
570
|
-
|
|
571
|
-
|
|
536
|
+
const textHeight = this._lines.length * this._fontOffset.height;
|
|
537
|
+
const totalHeight = textHeight + this._margin.getValueInPixel(this._host, parentMeasure.height) * 2;
|
|
572
538
|
this.height = Math.min(this._maxHeight.getValueInPixel(this._host, parentMeasure.height), totalHeight) + "px";
|
|
573
539
|
this._autoStretchHeight = true;
|
|
574
540
|
}
|
|
575
541
|
this._availableHeight = this._height.getValueInPixel(this._host, parentMeasure.height) - marginWidth;
|
|
576
542
|
if (this._isFocused) {
|
|
577
543
|
this._cursorInfo.currentLineIndex = 0;
|
|
578
|
-
|
|
579
|
-
|
|
544
|
+
let lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
|
|
545
|
+
let tmpLength = 0;
|
|
580
546
|
while (tmpLength + lineLength <= this._cursorInfo.globalStartIndex) {
|
|
581
547
|
tmpLength += lineLength;
|
|
582
548
|
if (this._cursorInfo.currentLineIndex < this._lines.length - 1) {
|
|
@@ -585,7 +551,7 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
585
551
|
}
|
|
586
552
|
}
|
|
587
553
|
}
|
|
588
|
-
}
|
|
554
|
+
}
|
|
589
555
|
/**
|
|
590
556
|
* Processing of child after the parent measurement update
|
|
591
557
|
*
|
|
@@ -594,11 +560,11 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
594
560
|
* @hidden
|
|
595
561
|
*/
|
|
596
562
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
597
|
-
|
|
563
|
+
_additionalProcessing(parentMeasure, context) {
|
|
598
564
|
this._clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, parentMeasure.width);
|
|
599
565
|
this._clipTextTop = this._currentMeasure.top + this._margin.getValueInPixel(this._host, parentMeasure.height);
|
|
600
566
|
if (this._isFocused && this._lines[this._cursorInfo.currentLineIndex].width > this._availableWidth) {
|
|
601
|
-
|
|
567
|
+
const textLeft = this._clipTextLeft - this._lines[this._cursorInfo.currentLineIndex].width + this._availableWidth;
|
|
602
568
|
if (!this._scrollLeft) {
|
|
603
569
|
this._scrollLeft = textLeft;
|
|
604
570
|
}
|
|
@@ -607,8 +573,8 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
607
573
|
this._scrollLeft = this._clipTextLeft;
|
|
608
574
|
}
|
|
609
575
|
if (this._isFocused && !this._autoStretchHeight) {
|
|
610
|
-
|
|
611
|
-
|
|
576
|
+
const selectedHeight = (this._cursorInfo.currentLineIndex + 1) * this._fontOffset.height;
|
|
577
|
+
const textTop = this._clipTextTop - selectedHeight;
|
|
612
578
|
if (!this._scrollTop) {
|
|
613
579
|
this._scrollTop = textTop;
|
|
614
580
|
}
|
|
@@ -619,10 +585,10 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
619
585
|
// Flush the highlighted text each frame
|
|
620
586
|
this.highlightedText = "";
|
|
621
587
|
this.onLinesReadyObservable.notifyObservers(this);
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
588
|
+
}
|
|
589
|
+
_drawText(text, textWidth, y, context) {
|
|
590
|
+
const width = this._currentMeasure.width;
|
|
591
|
+
let x = this._scrollLeft;
|
|
626
592
|
switch (this._textHorizontalAlignment) {
|
|
627
593
|
case Control.HORIZONTAL_ALIGNMENT_LEFT:
|
|
628
594
|
x += 0;
|
|
@@ -644,29 +610,29 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
644
610
|
context.strokeText(text, this._currentMeasure.left + x, y);
|
|
645
611
|
}
|
|
646
612
|
context.fillText(text, x, y);
|
|
647
|
-
}
|
|
613
|
+
}
|
|
648
614
|
/**
|
|
649
615
|
* Copy the text in the clipboard
|
|
650
616
|
*
|
|
651
617
|
* @param ev The clipboard event
|
|
652
618
|
* @hidden
|
|
653
619
|
*/
|
|
654
|
-
|
|
620
|
+
_onCopyText(ev) {
|
|
655
621
|
this._isTextHighlightOn = false;
|
|
656
622
|
//when write permission to clipbaord data is denied
|
|
657
623
|
try {
|
|
658
624
|
ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
|
|
659
625
|
}
|
|
660
|
-
catch
|
|
626
|
+
catch { } //pass
|
|
661
627
|
this._host.clipboardData = this._highlightedText;
|
|
662
|
-
}
|
|
628
|
+
}
|
|
663
629
|
/**
|
|
664
630
|
* Cut the text and copy it in the clipboard
|
|
665
631
|
*
|
|
666
632
|
* @param ev The clipboard event
|
|
667
633
|
* @hidden
|
|
668
634
|
*/
|
|
669
|
-
|
|
635
|
+
_onCutText(ev) {
|
|
670
636
|
if (!this._highlightedText) {
|
|
671
637
|
return;
|
|
672
638
|
}
|
|
@@ -674,19 +640,19 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
674
640
|
try {
|
|
675
641
|
ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
|
|
676
642
|
}
|
|
677
|
-
catch
|
|
643
|
+
catch { } //pass
|
|
678
644
|
this._host.clipboardData = this._highlightedText;
|
|
679
645
|
this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex);
|
|
680
646
|
this._textHasChanged();
|
|
681
|
-
}
|
|
647
|
+
}
|
|
682
648
|
/**
|
|
683
649
|
* Paste the copied text from the clipboard
|
|
684
650
|
*
|
|
685
651
|
* @param ev The clipboard event
|
|
686
652
|
* @hidden
|
|
687
653
|
*/
|
|
688
|
-
|
|
689
|
-
|
|
654
|
+
_onPasteText(ev) {
|
|
655
|
+
let data = "";
|
|
690
656
|
if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
|
|
691
657
|
data = ev.clipboardData.getData("text/plain");
|
|
692
658
|
}
|
|
@@ -696,15 +662,14 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
696
662
|
}
|
|
697
663
|
this._isTextHighlightOn = false;
|
|
698
664
|
this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex, data);
|
|
699
|
-
|
|
665
|
+
const deltaIndex = data.length - (this._cursorInfo.globalEndIndex - this._cursorInfo.globalStartIndex);
|
|
700
666
|
this._cursorInfo.globalStartIndex += deltaIndex;
|
|
701
667
|
this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
|
|
702
668
|
this._textHasChanged();
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
this.
|
|
707
|
-
this._scrollTop = (_b = this._scrollTop) !== null && _b !== void 0 ? _b : 0;
|
|
669
|
+
}
|
|
670
|
+
_draw(context) {
|
|
671
|
+
this._scrollLeft = this._scrollLeft ?? 0;
|
|
672
|
+
this._scrollTop = this._scrollTop ?? 0;
|
|
708
673
|
context.save();
|
|
709
674
|
this._applyStates(context);
|
|
710
675
|
if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
|
|
@@ -733,9 +698,9 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
733
698
|
if (this.color) {
|
|
734
699
|
context.fillStyle = this.color;
|
|
735
700
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
701
|
+
const height = this._currentMeasure.height;
|
|
702
|
+
const width = this._currentMeasure.width;
|
|
703
|
+
let rootY = 0;
|
|
739
704
|
switch (this._textVerticalAlignment) {
|
|
740
705
|
case Control.VERTICAL_ALIGNMENT_TOP:
|
|
741
706
|
rootY = this._fontOffset.ascent;
|
|
@@ -755,8 +720,8 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
755
720
|
context.clip();
|
|
756
721
|
// Text
|
|
757
722
|
rootY += this._scrollTop;
|
|
758
|
-
for (
|
|
759
|
-
|
|
723
|
+
for (let i = 0; i < this._lines.length; i++) {
|
|
724
|
+
const line = this._lines[i];
|
|
760
725
|
if (i !== 0 && this._lineSpacing.internalValue !== 0) {
|
|
761
726
|
if (this._lineSpacing.isPixel) {
|
|
762
727
|
rootY += this._lineSpacing.getValue(this._host);
|
|
@@ -773,7 +738,7 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
773
738
|
if (this._isFocused) {
|
|
774
739
|
// Render cursor
|
|
775
740
|
if (!this._blinkIsEven || this._isTextHighlightOn) {
|
|
776
|
-
|
|
741
|
+
let cursorLeft = this._scrollLeft + context.measureText(this._lines[this._cursorInfo.currentLineIndex].text.substr(0, this._cursorInfo.relativeStartIndex)).width;
|
|
777
742
|
if (cursorLeft < this._clipTextLeft) {
|
|
778
743
|
this._scrollLeft += this._clipTextLeft - cursorLeft;
|
|
779
744
|
cursorLeft = this._clipTextLeft;
|
|
@@ -784,7 +749,7 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
784
749
|
cursorLeft = this._clipTextLeft + this._availableWidth;
|
|
785
750
|
this._markAsDirty();
|
|
786
751
|
}
|
|
787
|
-
|
|
752
|
+
let cursorTop = this._scrollTop + this._cursorInfo.currentLineIndex * this._fontOffset.height; //cursorTop distance from top to cursor start
|
|
788
753
|
if (cursorTop < this._clipTextTop) {
|
|
789
754
|
this._scrollTop += this._clipTextTop - cursorTop;
|
|
790
755
|
cursorTop = this._clipTextTop;
|
|
@@ -806,12 +771,12 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
806
771
|
this._highlightedText = this.text.substring(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex);
|
|
807
772
|
context.globalAlpha = this._highligherOpacity;
|
|
808
773
|
context.fillStyle = this._textHighlightColor;
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
for (
|
|
813
|
-
|
|
814
|
-
|
|
774
|
+
const startLineIndex = Math.min(this._cursorInfo.currentLineIndex, this._highlightCursorInfo.initialLineIndex);
|
|
775
|
+
const endLineIndex = Math.max(this._cursorInfo.currentLineIndex, this._highlightCursorInfo.initialLineIndex);
|
|
776
|
+
let highlightRootY = this._scrollTop + startLineIndex * this._fontOffset.height;
|
|
777
|
+
for (let i = startLineIndex; i <= endLineIndex; i++) {
|
|
778
|
+
const line = this._lines[i];
|
|
779
|
+
let highlightRootX = this._scrollLeft;
|
|
815
780
|
switch (this._textHorizontalAlignment) {
|
|
816
781
|
case Control.HORIZONTAL_ALIGNMENT_LEFT:
|
|
817
782
|
highlightRootX += 0;
|
|
@@ -823,11 +788,11 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
823
788
|
highlightRootX += (width - line.width) / 2;
|
|
824
789
|
break;
|
|
825
790
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
791
|
+
const begin = i === startLineIndex ? this._cursorInfo.relativeStartIndex : 0;
|
|
792
|
+
const end = i === endLineIndex ? this._cursorInfo.relativeEndIndex : line.text.length;
|
|
793
|
+
const leftOffsetWidth = context.measureText(line.text.substr(0, begin)).width;
|
|
794
|
+
const selectedText = line.text.substring(begin, end);
|
|
795
|
+
const hightlightWidth = context.measureText(selectedText).width;
|
|
831
796
|
context.fillRect(highlightRootX + leftOffsetWidth, highlightRootY, hightlightWidth, this._fontOffset.height);
|
|
832
797
|
highlightRootY += this._fontOffset.height;
|
|
833
798
|
}
|
|
@@ -852,24 +817,23 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
852
817
|
context.lineWidth = this._thickness;
|
|
853
818
|
context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
|
|
854
819
|
}
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
var _this = this;
|
|
820
|
+
}
|
|
821
|
+
_resetBlinking() {
|
|
858
822
|
clearTimeout(this._blinkTimeout);
|
|
859
|
-
this._blinkTimeout = setTimeout(
|
|
860
|
-
|
|
861
|
-
|
|
823
|
+
this._blinkTimeout = setTimeout(() => {
|
|
824
|
+
this._blinkIsEven = !this._blinkIsEven;
|
|
825
|
+
this._markAsDirty();
|
|
862
826
|
}, 500);
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
|
|
827
|
+
}
|
|
828
|
+
_applyStates(context) {
|
|
829
|
+
super._applyStates(context);
|
|
866
830
|
if (this.outlineWidth) {
|
|
867
831
|
context.lineWidth = this.outlineWidth;
|
|
868
832
|
context.strokeStyle = this.outlineColor;
|
|
869
833
|
}
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
if (!
|
|
834
|
+
}
|
|
835
|
+
_onPointerDown(target, coordinates, pointerId, buttonIndex, pi) {
|
|
836
|
+
if (!super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi)) {
|
|
873
837
|
return false;
|
|
874
838
|
}
|
|
875
839
|
this._clickedCoordinateX = coordinates.x;
|
|
@@ -889,9 +853,9 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
889
853
|
}
|
|
890
854
|
this._host.focusedControl = this;
|
|
891
855
|
return true;
|
|
892
|
-
}
|
|
856
|
+
}
|
|
893
857
|
// for textselection
|
|
894
|
-
|
|
858
|
+
_onPointerMove(target, coordinates, pointerId, pi) {
|
|
895
859
|
// Avoid Chromium-like beahavior when this event is fired right after onPointerDown
|
|
896
860
|
if (pi.event.movementX === 0 && pi.event.movementY === 0) {
|
|
897
861
|
return;
|
|
@@ -907,13 +871,12 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
907
871
|
}
|
|
908
872
|
this._markAsDirty();
|
|
909
873
|
}
|
|
910
|
-
|
|
911
|
-
}
|
|
874
|
+
super._onPointerMove(target, coordinates, pointerId, pi);
|
|
875
|
+
}
|
|
912
876
|
/**
|
|
913
877
|
* Apply the correct position of cursor according to current modification
|
|
914
878
|
*/
|
|
915
|
-
|
|
916
|
-
var _a;
|
|
879
|
+
_updateCursorPosition() {
|
|
917
880
|
if (!this._isFocused) {
|
|
918
881
|
return;
|
|
919
882
|
}
|
|
@@ -927,16 +890,16 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
927
890
|
currentLineIndex: 0,
|
|
928
891
|
};
|
|
929
892
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
893
|
+
let globalIndex = 0;
|
|
894
|
+
let relativeIndex = 0;
|
|
895
|
+
const lastClickedCoordinateY = this._clickedCoordinateY - this._scrollTop;
|
|
896
|
+
const relativeCoordinateY = Math.floor(lastClickedCoordinateY / this._fontOffset.height);
|
|
934
897
|
this._cursorInfo.currentLineIndex = Math.min(Math.max(relativeCoordinateY, 0), this._lines.length - 1);
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
for (
|
|
939
|
-
|
|
898
|
+
let currentSize = 0;
|
|
899
|
+
const relativeXPosition = this._clickedCoordinateX - (this._scrollLeft ?? 0);
|
|
900
|
+
let previousDist = 0;
|
|
901
|
+
for (let index = 0; index < this._cursorInfo.currentLineIndex; index++) {
|
|
902
|
+
const line = this._lines[index];
|
|
940
903
|
globalIndex += line.text.length + line.lineEnding.length;
|
|
941
904
|
}
|
|
942
905
|
while (currentSize < relativeXPosition && this._lines[this._cursorInfo.currentLineIndex].text.length > relativeIndex) {
|
|
@@ -978,8 +941,8 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
978
941
|
// Standard behavior same as Current line is at least above the initial highlight index
|
|
979
942
|
this._cursorInfo.relativeStartIndex = 0;
|
|
980
943
|
this._cursorInfo.currentLineIndex = 0;
|
|
981
|
-
|
|
982
|
-
|
|
944
|
+
let lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
|
|
945
|
+
let tmpLength = 0;
|
|
983
946
|
while (tmpLength + lineLength <= this._cursorInfo.globalStartIndex) {
|
|
984
947
|
tmpLength += lineLength;
|
|
985
948
|
if (this._cursorInfo.currentLineIndex < this._lines.length - 1) {
|
|
@@ -1004,7 +967,7 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
1004
967
|
this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
|
|
1005
968
|
}
|
|
1006
969
|
}
|
|
1007
|
-
}
|
|
970
|
+
}
|
|
1008
971
|
/**
|
|
1009
972
|
* Update all values of cursor information based on cursorIndex value
|
|
1010
973
|
*
|
|
@@ -1012,18 +975,18 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
1012
975
|
* @hidden
|
|
1013
976
|
*/
|
|
1014
977
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1015
|
-
|
|
978
|
+
_updateValueFromCursorIndex(offset) {
|
|
1016
979
|
// Override to avoid parent behavior during _onPointerMove
|
|
1017
|
-
}
|
|
980
|
+
}
|
|
1018
981
|
/**
|
|
1019
982
|
* Select the word immediatly under the cursor on double click
|
|
1020
983
|
*
|
|
1021
984
|
* @param _evt Pointer informations of double click
|
|
1022
985
|
* @hidden
|
|
1023
986
|
*/
|
|
1024
|
-
|
|
987
|
+
_processDblClick(_evt) {
|
|
1025
988
|
//pre-find the start and end index of the word under cursor, speeds up the rendering
|
|
1026
|
-
|
|
989
|
+
let moveLeft, moveRight;
|
|
1027
990
|
do {
|
|
1028
991
|
moveLeft = this._cursorInfo.globalStartIndex > 0 && this._textWrapper.isWord(this._cursorInfo.globalStartIndex - 1) ? --this._cursorInfo.globalStartIndex : 0;
|
|
1029
992
|
moveRight =
|
|
@@ -1035,9 +998,9 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
1035
998
|
this._isTextHighlightOn = true;
|
|
1036
999
|
this._blinkIsEven = true;
|
|
1037
1000
|
this._markAsDirty();
|
|
1038
|
-
}
|
|
1001
|
+
}
|
|
1039
1002
|
/** @hidden */
|
|
1040
|
-
|
|
1003
|
+
_selectAllText() {
|
|
1041
1004
|
this._isTextHighlightOn = true;
|
|
1042
1005
|
this._blinkIsEven = true;
|
|
1043
1006
|
this._highlightCursorInfo = {
|
|
@@ -1053,19 +1016,17 @@ var InputTextArea = /** @class */ (function (_super) {
|
|
|
1053
1016
|
currentLineIndex: this._lines.length - 1,
|
|
1054
1017
|
};
|
|
1055
1018
|
this._markAsDirty();
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1019
|
+
}
|
|
1020
|
+
dipose() {
|
|
1021
|
+
super.dispose();
|
|
1059
1022
|
this.onLinesReadyObservable.clear();
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
}(InputText));
|
|
1069
|
-
export { InputTextArea };
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
__decorate([
|
|
1026
|
+
serialize()
|
|
1027
|
+
], InputTextArea.prototype, "autoStretchHeight", null);
|
|
1028
|
+
__decorate([
|
|
1029
|
+
serialize()
|
|
1030
|
+
], InputTextArea.prototype, "maxHeight", null);
|
|
1070
1031
|
RegisterClass("BABYLON.GUI.InputTextArea", InputTextArea);
|
|
1071
1032
|
//# sourceMappingURL=inputTextArea.js.map
|