@babylonjs/gui 5.0.0-rc.7 → 5.0.0-rc.9

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.
Files changed (203) hide show
  1. package/2D/adtInstrumentation.d.ts +52 -52
  2. package/2D/adtInstrumentation.js +126 -126
  3. package/2D/advancedDynamicTexture.d.ts +448 -448
  4. package/2D/advancedDynamicTexture.js +1318 -1318
  5. package/2D/controls/button.d.ts +135 -135
  6. package/2D/controls/button.js +276 -276
  7. package/2D/controls/checkbox.d.ts +59 -59
  8. package/2D/controls/checkbox.js +188 -188
  9. package/2D/controls/colorpicker.d.ts +103 -103
  10. package/2D/controls/colorpicker.js +1417 -1417
  11. package/2D/controls/container.d.ts +175 -175
  12. package/2D/controls/container.js +570 -570
  13. package/2D/controls/control.d.ts +866 -866
  14. package/2D/controls/control.js +2433 -2433
  15. package/2D/controls/displayGrid.d.ts +53 -53
  16. package/2D/controls/displayGrid.js +245 -245
  17. package/2D/controls/ellipse.d.ts +21 -21
  18. package/2D/controls/ellipse.js +85 -85
  19. package/2D/controls/focusableButton.d.ts +59 -59
  20. package/2D/controls/focusableButton.js +99 -99
  21. package/2D/controls/focusableControl.d.ts +34 -34
  22. package/2D/controls/focusableControl.js +1 -1
  23. package/2D/controls/grid.d.ts +139 -139
  24. package/2D/controls/grid.js +529 -529
  25. package/2D/controls/image.d.ts +204 -204
  26. package/2D/controls/image.js +887 -887
  27. package/2D/controls/index.d.ts +29 -29
  28. package/2D/controls/index.js +29 -29
  29. package/2D/controls/inputPassword.d.ts +8 -8
  30. package/2D/controls/inputPassword.js +25 -25
  31. package/2D/controls/inputText.d.ts +201 -201
  32. package/2D/controls/inputText.js +1119 -1119
  33. package/2D/controls/line.d.ts +66 -66
  34. package/2D/controls/line.js +271 -271
  35. package/2D/controls/multiLine.d.ts +75 -75
  36. package/2D/controls/multiLine.js +262 -262
  37. package/2D/controls/radioButton.d.ts +49 -49
  38. package/2D/controls/radioButton.js +205 -205
  39. package/2D/controls/rectangle.d.ts +29 -29
  40. package/2D/controls/rectangle.js +150 -150
  41. package/2D/controls/scrollViewers/scrollViewer.d.ts +182 -182
  42. package/2D/controls/scrollViewers/scrollViewer.js +677 -677
  43. package/2D/controls/scrollViewers/scrollViewerWindow.d.ts +57 -57
  44. package/2D/controls/scrollViewers/scrollViewerWindow.js +278 -278
  45. package/2D/controls/selector.d.ts +263 -263
  46. package/2D/controls/selector.js +692 -692
  47. package/2D/controls/sliders/baseSlider.d.ts +82 -82
  48. package/2D/controls/sliders/baseSlider.js +347 -347
  49. package/2D/controls/sliders/imageBasedSlider.d.ts +49 -49
  50. package/2D/controls/sliders/imageBasedSlider.js +192 -192
  51. package/2D/controls/sliders/imageScrollBar.d.ts +65 -65
  52. package/2D/controls/sliders/imageScrollBar.js +263 -263
  53. package/2D/controls/sliders/scrollBar.d.ts +38 -38
  54. package/2D/controls/sliders/scrollBar.js +143 -143
  55. package/2D/controls/sliders/slider.d.ts +35 -35
  56. package/2D/controls/sliders/slider.js +271 -271
  57. package/2D/controls/stackPanel.d.ts +64 -64
  58. package/2D/controls/stackPanel.js +246 -246
  59. package/2D/controls/statics.d.ts +6 -6
  60. package/2D/controls/statics.js +49 -49
  61. package/2D/controls/textBlock.d.ts +175 -175
  62. package/2D/controls/textBlock.js +603 -603
  63. package/2D/controls/textWrapper.d.ts +13 -13
  64. package/2D/controls/textWrapper.js +101 -101
  65. package/2D/controls/toggleButton.d.ts +117 -117
  66. package/2D/controls/toggleButton.js +268 -268
  67. package/2D/controls/virtualKeyboard.d.ts +96 -96
  68. package/2D/controls/virtualKeyboard.js +256 -256
  69. package/2D/index.d.ts +9 -9
  70. package/2D/index.js +9 -9
  71. package/2D/math2D.d.ts +117 -117
  72. package/2D/math2D.js +221 -221
  73. package/2D/measure.d.ts +77 -77
  74. package/2D/measure.js +139 -139
  75. package/2D/multiLinePoint.d.ts +47 -47
  76. package/2D/multiLinePoint.js +127 -127
  77. package/2D/style.d.ts +46 -46
  78. package/2D/style.js +97 -97
  79. package/2D/valueAndUnit.d.ts +89 -89
  80. package/2D/valueAndUnit.js +226 -226
  81. package/2D/xmlLoader.d.ts +60 -60
  82. package/2D/xmlLoader.js +348 -348
  83. package/3D/behaviors/defaultBehavior.d.ts +73 -73
  84. package/3D/behaviors/defaultBehavior.js +121 -121
  85. package/3D/controls/abstractButton3D.d.ts +15 -15
  86. package/3D/controls/abstractButton3D.js +25 -25
  87. package/3D/controls/button3D.d.ts +30 -30
  88. package/3D/controls/button3D.js +93 -93
  89. package/3D/controls/container3D.d.ts +72 -72
  90. package/3D/controls/container3D.js +139 -139
  91. package/3D/controls/contentDisplay3D.d.ts +30 -30
  92. package/3D/controls/contentDisplay3D.js +79 -79
  93. package/3D/controls/control3D.d.ts +201 -201
  94. package/3D/controls/control3D.js +445 -445
  95. package/3D/controls/cylinderPanel.d.ts +17 -17
  96. package/3D/controls/cylinderPanel.js +66 -66
  97. package/3D/controls/handMenu.d.ts +28 -28
  98. package/3D/controls/handMenu.js +47 -47
  99. package/3D/controls/holographicBackplate.d.ts +49 -49
  100. package/3D/controls/holographicBackplate.js +120 -120
  101. package/3D/controls/holographicButton.d.ts +84 -84
  102. package/3D/controls/holographicButton.js +339 -339
  103. package/3D/controls/holographicSlate.d.ts +131 -131
  104. package/3D/controls/holographicSlate.js +431 -431
  105. package/3D/controls/index.d.ts +21 -21
  106. package/3D/controls/index.js +21 -21
  107. package/3D/controls/meshButton3D.d.ts +21 -21
  108. package/3D/controls/meshButton3D.js +62 -62
  109. package/3D/controls/nearMenu.d.ts +44 -44
  110. package/3D/controls/nearMenu.js +114 -114
  111. package/3D/controls/planePanel.d.ts +9 -9
  112. package/3D/controls/planePanel.js +36 -36
  113. package/3D/controls/scatterPanel.d.ts +18 -18
  114. package/3D/controls/scatterPanel.js +108 -108
  115. package/3D/controls/slider3D.d.ts +81 -81
  116. package/3D/controls/slider3D.js +268 -268
  117. package/3D/controls/spherePanel.d.ts +17 -17
  118. package/3D/controls/spherePanel.js +67 -67
  119. package/3D/controls/stackPanel3D.d.ts +22 -22
  120. package/3D/controls/stackPanel3D.js +107 -107
  121. package/3D/controls/touchButton3D.d.ts +80 -80
  122. package/3D/controls/touchButton3D.js +233 -233
  123. package/3D/controls/touchHolographicButton.d.ts +110 -110
  124. package/3D/controls/touchHolographicButton.js +445 -445
  125. package/3D/controls/touchHolographicMenu.d.ts +61 -61
  126. package/3D/controls/touchHolographicMenu.js +149 -149
  127. package/3D/controls/touchMeshButton3D.d.ts +21 -21
  128. package/3D/controls/touchMeshButton3D.js +62 -62
  129. package/3D/controls/volumeBasedPanel.d.ts +53 -53
  130. package/3D/controls/volumeBasedPanel.js +174 -174
  131. package/3D/gizmos/gizmoHandle.d.ts +108 -108
  132. package/3D/gizmos/gizmoHandle.js +209 -209
  133. package/3D/gizmos/index.d.ts +2 -2
  134. package/3D/gizmos/index.js +2 -2
  135. package/3D/gizmos/slateGizmo.d.ts +57 -57
  136. package/3D/gizmos/slateGizmo.js +369 -369
  137. package/3D/gui3DManager.d.ts +94 -94
  138. package/3D/gui3DManager.js +257 -257
  139. package/3D/index.d.ts +5 -5
  140. package/3D/index.js +5 -5
  141. package/3D/materials/fluent/fluentMaterial.d.ts +90 -90
  142. package/3D/materials/fluent/fluentMaterial.js +292 -292
  143. package/3D/materials/fluent/index.d.ts +1 -1
  144. package/3D/materials/fluent/index.js +1 -1
  145. package/3D/materials/fluent/shaders/fluent.fragment.d.ts +5 -5
  146. package/3D/materials/fluent/shaders/fluent.fragment.js +8 -8
  147. package/3D/materials/fluent/shaders/fluent.vertex.d.ts +5 -5
  148. package/3D/materials/fluent/shaders/fluent.vertex.js +8 -8
  149. package/3D/materials/fluentBackplate/fluentBackplateMaterial.d.ts +154 -154
  150. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +469 -469
  151. package/3D/materials/fluentBackplate/index.d.ts +1 -1
  152. package/3D/materials/fluentBackplate/index.js +1 -1
  153. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.d.ts +5 -5
  154. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js +8 -8
  155. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.d.ts +5 -5
  156. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js +8 -8
  157. package/3D/materials/fluentButton/fluentButtonMaterial.d.ts +189 -189
  158. package/3D/materials/fluentButton/fluentButtonMaterial.js +539 -539
  159. package/3D/materials/fluentButton/index.d.ts +1 -1
  160. package/3D/materials/fluentButton/index.js +1 -1
  161. package/3D/materials/fluentButton/shaders/fluentButton.fragment.d.ts +5 -5
  162. package/3D/materials/fluentButton/shaders/fluentButton.fragment.js +8 -8
  163. package/3D/materials/fluentButton/shaders/fluentButton.vertex.d.ts +5 -5
  164. package/3D/materials/fluentButton/shaders/fluentButton.vertex.js +8 -8
  165. package/3D/materials/fluentMaterial.d.ts +4 -4
  166. package/3D/materials/fluentMaterial.js +4 -4
  167. package/3D/materials/handle/handleMaterial.d.ts +68 -68
  168. package/3D/materials/handle/handleMaterial.js +126 -126
  169. package/3D/materials/handle/index.d.ts +1 -1
  170. package/3D/materials/handle/index.js +1 -1
  171. package/3D/materials/handle/shaders/handle.fragment.d.ts +5 -5
  172. package/3D/materials/handle/shaders/handle.fragment.js +8 -8
  173. package/3D/materials/handle/shaders/handle.vertex.d.ts +5 -5
  174. package/3D/materials/handle/shaders/handle.vertex.js +8 -8
  175. package/3D/materials/index.d.ts +5 -5
  176. package/3D/materials/index.js +5 -5
  177. package/3D/materials/mrdl/index.d.ts +3 -3
  178. package/3D/materials/mrdl/index.js +3 -3
  179. package/3D/materials/mrdl/mrdlBackplateMaterial.d.ts +147 -147
  180. package/3D/materials/mrdl/mrdlBackplateMaterial.js +436 -436
  181. package/3D/materials/mrdl/mrdlSliderBarMaterial.d.ts +333 -333
  182. package/3D/materials/mrdl/mrdlSliderBarMaterial.js +851 -851
  183. package/3D/materials/mrdl/mrdlSliderThumbMaterial.d.ts +333 -333
  184. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +851 -851
  185. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.d.ts +5 -5
  186. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js +8 -8
  187. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.d.ts +5 -5
  188. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js +8 -8
  189. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.d.ts +5 -5
  190. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js +8 -8
  191. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.d.ts +5 -5
  192. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js +8 -8
  193. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.d.ts +5 -5
  194. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js +8 -8
  195. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.d.ts +5 -5
  196. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js +8 -8
  197. package/3D/vector3WithInfo.d.ts +16 -16
  198. package/3D/vector3WithInfo.js +23 -23
  199. package/index.d.ts +2 -2
  200. package/index.js +2 -2
  201. package/legacy/legacy.d.ts +1 -1
  202. package/legacy/legacy.js +13 -13
  203. package/package.json +2 -2
@@ -1,1120 +1,1120 @@
1
- import { __decorate, __extends } from "tslib";
2
- import { Observable } from "@babylonjs/core/Misc/observable.js";
3
- import { ClipboardEventTypes } from "@babylonjs/core/Events/clipboardEvents.js";
4
- import { PointerEventTypes } from "@babylonjs/core/Events/pointerEvents.js";
5
- import { Control } from "./control.js";
6
- import { ValueAndUnit } from "../valueAndUnit.js";
7
- import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
8
- import { TextWrapper } from "./textWrapper.js";
9
- import { serialize } from "@babylonjs/core/Misc/decorators.js";
10
- /**
11
- * Class used to create input text control
12
- */
13
- var InputText = /** @class */ (function (_super) {
14
- __extends(InputText, _super);
15
- /**
16
- * Creates a new InputText
17
- * @param name defines the control name
18
- * @param text defines the text of the control
19
- */
20
- function InputText(name, text) {
21
- if (text === void 0) { text = ""; }
22
- var _this = _super.call(this, name) || this;
23
- _this.name = name;
24
- _this._placeholderText = "";
25
- _this._background = "#222222";
26
- _this._focusedBackground = "#000000";
27
- _this._focusedColor = "white";
28
- _this._placeholderColor = "gray";
29
- _this._thickness = 1;
30
- _this._margin = new ValueAndUnit(10, ValueAndUnit.UNITMODE_PIXEL);
31
- _this._autoStretchWidth = true;
32
- _this._maxWidth = new ValueAndUnit(1, ValueAndUnit.UNITMODE_PERCENTAGE, false);
33
- _this._isFocused = false;
34
- _this._blinkIsEven = false;
35
- _this._cursorOffset = 0;
36
- _this._deadKey = false;
37
- _this._addKey = true;
38
- _this._currentKey = "";
39
- _this._isTextHighlightOn = false;
40
- _this._textHighlightColor = "#d5e0ff";
41
- _this._highligherOpacity = 0.4;
42
- _this._highlightedText = "";
43
- _this._startHighlightIndex = 0;
44
- _this._endHighlightIndex = 0;
45
- _this._cursorIndex = -1;
46
- _this._onFocusSelectAll = false;
47
- _this._isPointerDown = false;
48
- /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
49
- _this.promptMessage = "Please enter text:";
50
- /** Force disable prompt on mobile device */
51
- _this.disableMobilePrompt = false;
52
- /** Observable raised when the text changes */
53
- _this.onTextChangedObservable = new Observable();
54
- /** Observable raised just before an entered character is to be added */
55
- _this.onBeforeKeyAddObservable = new Observable();
56
- /** Observable raised when the control gets the focus */
57
- _this.onFocusObservable = new Observable();
58
- /** Observable raised when the control loses the focus */
59
- _this.onBlurObservable = new Observable();
60
- /**Observable raised when the text is highlighted */
61
- _this.onTextHighlightObservable = new Observable();
62
- /**Observable raised when copy event is triggered */
63
- _this.onTextCopyObservable = new Observable();
64
- /** Observable raised when cut event is triggered */
65
- _this.onTextCutObservable = new Observable();
66
- /** Observable raised when paste event is triggered */
67
- _this.onTextPasteObservable = new Observable();
68
- /** Observable raised when a key event was processed */
69
- _this.onKeyboardEventProcessedObservable = new Observable();
70
- _this.text = text;
71
- _this.isPointerBlocker = true;
72
- return _this;
73
- }
74
- Object.defineProperty(InputText.prototype, "maxWidth", {
75
- /** Gets or sets the maximum width allowed by the control */
76
- get: function () {
77
- return this._maxWidth.toString(this._host);
78
- },
79
- set: function (value) {
80
- if (this._maxWidth.toString(this._host) === value) {
81
- return;
82
- }
83
- if (this._maxWidth.fromString(value)) {
84
- this._markAsDirty();
85
- }
86
- },
87
- enumerable: false,
88
- configurable: true
89
- });
90
- Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
91
- /** Gets the maximum width allowed by the control in pixels */
92
- get: function () {
93
- return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
94
- },
95
- enumerable: false,
96
- configurable: true
97
- });
98
- Object.defineProperty(InputText.prototype, "highligherOpacity", {
99
- /** Gets or sets the text highlighter transparency; default: 0.4 */
100
- get: function () {
101
- return this._highligherOpacity;
102
- },
103
- set: function (value) {
104
- if (this._highligherOpacity === value) {
105
- return;
106
- }
107
- this._highligherOpacity = value;
108
- this._markAsDirty();
109
- },
110
- enumerable: false,
111
- configurable: true
112
- });
113
- Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
114
- /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
115
- get: function () {
116
- return this._onFocusSelectAll;
117
- },
118
- set: function (value) {
119
- if (this._onFocusSelectAll === value) {
120
- return;
121
- }
122
- this._onFocusSelectAll = value;
123
- this._markAsDirty();
124
- },
125
- enumerable: false,
126
- configurable: true
127
- });
128
- Object.defineProperty(InputText.prototype, "textHighlightColor", {
129
- /** Gets or sets the text hightlight color */
130
- get: function () {
131
- return this._textHighlightColor;
132
- },
133
- set: function (value) {
134
- if (this._textHighlightColor === value) {
135
- return;
136
- }
137
- this._textHighlightColor = value;
138
- this._markAsDirty();
139
- },
140
- enumerable: false,
141
- configurable: true
142
- });
143
- Object.defineProperty(InputText.prototype, "margin", {
144
- /** Gets or sets control margin */
145
- get: function () {
146
- return this._margin.toString(this._host);
147
- },
148
- set: function (value) {
149
- if (this._margin.toString(this._host) === value) {
150
- return;
151
- }
152
- if (this._margin.fromString(value)) {
153
- this._markAsDirty();
154
- }
155
- },
156
- enumerable: false,
157
- configurable: true
158
- });
159
- Object.defineProperty(InputText.prototype, "marginInPixels", {
160
- /** Gets control margin in pixels */
161
- get: function () {
162
- return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
163
- },
164
- enumerable: false,
165
- configurable: true
166
- });
167
- Object.defineProperty(InputText.prototype, "autoStretchWidth", {
168
- /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
169
- get: function () {
170
- return this._autoStretchWidth;
171
- },
172
- set: function (value) {
173
- if (this._autoStretchWidth === value) {
174
- return;
175
- }
176
- this._autoStretchWidth = value;
177
- this._markAsDirty();
178
- },
179
- enumerable: false,
180
- configurable: true
181
- });
182
- Object.defineProperty(InputText.prototype, "thickness", {
183
- /** Gets or sets border thickness */
184
- get: function () {
185
- return this._thickness;
186
- },
187
- set: function (value) {
188
- if (this._thickness === value) {
189
- return;
190
- }
191
- this._thickness = value;
192
- this._markAsDirty();
193
- },
194
- enumerable: false,
195
- configurable: true
196
- });
197
- Object.defineProperty(InputText.prototype, "focusedBackground", {
198
- /** Gets or sets the background color when focused */
199
- get: function () {
200
- return this._focusedBackground;
201
- },
202
- set: function (value) {
203
- if (this._focusedBackground === value) {
204
- return;
205
- }
206
- this._focusedBackground = value;
207
- this._markAsDirty();
208
- },
209
- enumerable: false,
210
- configurable: true
211
- });
212
- Object.defineProperty(InputText.prototype, "focusedColor", {
213
- /** Gets or sets the background color when focused */
214
- get: function () {
215
- return this._focusedColor;
216
- },
217
- set: function (value) {
218
- if (this._focusedColor === value) {
219
- return;
220
- }
221
- this._focusedColor = value;
222
- this._markAsDirty();
223
- },
224
- enumerable: false,
225
- configurable: true
226
- });
227
- Object.defineProperty(InputText.prototype, "background", {
228
- /** Gets or sets the background color */
229
- get: function () {
230
- return this._background;
231
- },
232
- set: function (value) {
233
- if (this._background === value) {
234
- return;
235
- }
236
- this._background = value;
237
- this._markAsDirty();
238
- },
239
- enumerable: false,
240
- configurable: true
241
- });
242
- Object.defineProperty(InputText.prototype, "placeholderColor", {
243
- /** Gets or sets the placeholder color */
244
- get: function () {
245
- return this._placeholderColor;
246
- },
247
- set: function (value) {
248
- if (this._placeholderColor === value) {
249
- return;
250
- }
251
- this._placeholderColor = value;
252
- this._markAsDirty();
253
- },
254
- enumerable: false,
255
- configurable: true
256
- });
257
- Object.defineProperty(InputText.prototype, "placeholderText", {
258
- /** Gets or sets the text displayed when the control is empty */
259
- get: function () {
260
- return this._placeholderText;
261
- },
262
- set: function (value) {
263
- if (this._placeholderText === value) {
264
- return;
265
- }
266
- this._placeholderText = value;
267
- this._markAsDirty();
268
- },
269
- enumerable: false,
270
- configurable: true
271
- });
272
- Object.defineProperty(InputText.prototype, "deadKey", {
273
- /** Gets or sets the dead key flag */
274
- get: function () {
275
- return this._deadKey;
276
- },
277
- set: function (flag) {
278
- this._deadKey = flag;
279
- },
280
- enumerable: false,
281
- configurable: true
282
- });
283
- Object.defineProperty(InputText.prototype, "highlightedText", {
284
- /** Gets or sets the highlight text */
285
- get: function () {
286
- return this._highlightedText;
287
- },
288
- set: function (text) {
289
- if (this._highlightedText === text) {
290
- return;
291
- }
292
- this._highlightedText = text;
293
- this._markAsDirty();
294
- },
295
- enumerable: false,
296
- configurable: true
297
- });
298
- Object.defineProperty(InputText.prototype, "addKey", {
299
- /** Gets or sets if the current key should be added */
300
- get: function () {
301
- return this._addKey;
302
- },
303
- set: function (flag) {
304
- this._addKey = flag;
305
- },
306
- enumerable: false,
307
- configurable: true
308
- });
309
- Object.defineProperty(InputText.prototype, "currentKey", {
310
- /** Gets or sets the value of the current key being entered */
311
- get: function () {
312
- return this._currentKey;
313
- },
314
- set: function (key) {
315
- this._currentKey = key;
316
- },
317
- enumerable: false,
318
- configurable: true
319
- });
320
- Object.defineProperty(InputText.prototype, "text", {
321
- /** Gets or sets the text displayed in the control */
322
- get: function () {
323
- return this._textWrapper.text;
324
- },
325
- set: function (value) {
326
- var valueAsString = value.toString(); // Forcing convertion
327
- if (!this._textWrapper) {
328
- this._textWrapper = new TextWrapper();
329
- }
330
- if (this._textWrapper.text === valueAsString) {
331
- return;
332
- }
333
- this._textWrapper.text = valueAsString;
334
- this._textHasChanged();
335
- },
336
- enumerable: false,
337
- configurable: true
338
- });
339
- InputText.prototype._textHasChanged = function () {
340
- this._markAsDirty();
341
- this.onTextChangedObservable.notifyObservers(this);
342
- };
343
- Object.defineProperty(InputText.prototype, "width", {
344
- /** Gets or sets control width */
345
- get: function () {
346
- return this._width.toString(this._host);
347
- },
348
- set: function (value) {
349
- if (this._width.toString(this._host) === value) {
350
- return;
351
- }
352
- if (this._width.fromString(value)) {
353
- this._markAsDirty();
354
- }
355
- this.autoStretchWidth = false;
356
- },
357
- enumerable: false,
358
- configurable: true
359
- });
360
- /** @hidden */
361
- InputText.prototype.onBlur = function () {
362
- this._isFocused = false;
363
- this._scrollLeft = null;
364
- this._cursorOffset = 0;
365
- clearTimeout(this._blinkTimeout);
366
- this._markAsDirty();
367
- this.onBlurObservable.notifyObservers(this);
368
- this._host.unRegisterClipboardEvents();
369
- if (this._onClipboardObserver) {
370
- this._host.onClipboardObservable.remove(this._onClipboardObserver);
371
- }
372
- var scene = this._host.getScene();
373
- if (this._onPointerDblTapObserver && scene) {
374
- scene.onPointerObservable.remove(this._onPointerDblTapObserver);
375
- }
376
- };
377
- /** @hidden */
378
- InputText.prototype.onFocus = function () {
379
- var _this = this;
380
- if (!this._isEnabled) {
381
- return;
382
- }
383
- this._scrollLeft = null;
384
- this._isFocused = true;
385
- this._blinkIsEven = false;
386
- this._cursorOffset = 0;
387
- this._markAsDirty();
388
- this.onFocusObservable.notifyObservers(this);
389
- if (this._focusedBy === "touch" && !this.disableMobilePrompt) {
390
- var value = prompt(this.promptMessage);
391
- if (value !== null) {
392
- this.text = value;
393
- }
394
- this._host.focusedControl = null;
395
- return;
396
- }
397
- this._host.registerClipboardEvents();
398
- this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
399
- // process clipboard event, can be configured.
400
- switch (clipboardInfo.type) {
401
- case ClipboardEventTypes.COPY:
402
- _this._onCopyText(clipboardInfo.event);
403
- _this.onTextCopyObservable.notifyObservers(_this);
404
- break;
405
- case ClipboardEventTypes.CUT:
406
- _this._onCutText(clipboardInfo.event);
407
- _this.onTextCutObservable.notifyObservers(_this);
408
- break;
409
- case ClipboardEventTypes.PASTE:
410
- _this._onPasteText(clipboardInfo.event);
411
- _this.onTextPasteObservable.notifyObservers(_this);
412
- break;
413
- default:
414
- return;
415
- }
416
- });
417
- var scene = this._host.getScene();
418
- if (scene) {
419
- //register the pointer double tap event
420
- this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
421
- if (!_this._isFocused) {
422
- return;
423
- }
424
- if (pointerInfo.type === PointerEventTypes.POINTERDOUBLETAP) {
425
- _this._processDblClick(pointerInfo);
426
- }
427
- });
428
- }
429
- if (this._onFocusSelectAll) {
430
- this._selectAllText();
431
- }
432
- };
433
- /**
434
- * Function to focus an inputText programmatically
435
- */
436
- InputText.prototype.focus = function () {
437
- this._host.moveFocusToControl(this);
438
- };
439
- /**
440
- * Function to unfocus an inputText programmatically
441
- */
442
- InputText.prototype.blur = function () {
443
- this._host.focusedControl = null;
444
- };
445
- InputText.prototype._getTypeName = function () {
446
- return "InputText";
447
- };
448
- /**
449
- * Function called to get the list of controls that should not steal the focus from this control
450
- * @returns an array of controls
451
- */
452
- InputText.prototype.keepsFocusWith = function () {
453
- if (!this._connectedVirtualKeyboard) {
454
- return null;
455
- }
456
- return [this._connectedVirtualKeyboard];
457
- };
458
- /**
459
- * @param keyCode
460
- * @param key
461
- * @param evt
462
- * @hidden
463
- */
464
- InputText.prototype.processKey = function (keyCode, key, evt) {
465
- if (this.isReadOnly) {
466
- return;
467
- }
468
- //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
469
- if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
470
- return;
471
- }
472
- //select all
473
- if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
474
- this._selectAllText();
475
- evt.preventDefault();
476
- return;
477
- }
478
- // Specific cases
479
- switch (keyCode) {
480
- case 32: //SPACE
481
- key = " "; //ie11 key for space is "Spacebar"
482
- break;
483
- case 191: //SLASH
484
- if (evt) {
485
- evt.preventDefault();
486
- }
487
- break;
488
- case 8: // BACKSPACE
489
- if (this._textWrapper.text && this._textWrapper.length > 0) {
490
- //delete the highlighted text
491
- if (this._isTextHighlightOn) {
492
- this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
493
- this._textHasChanged();
494
- this._isTextHighlightOn = false;
495
- this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
496
- this._blinkIsEven = false;
497
- if (evt) {
498
- evt.preventDefault();
499
- }
500
- return;
501
- }
502
- //delete single character
503
- if (this._cursorOffset === 0) {
504
- this.text = this._textWrapper.substr(0, this._textWrapper.length - 1);
505
- }
506
- else {
507
- var deletePosition = this._textWrapper.length - this._cursorOffset;
508
- if (deletePosition > 0) {
509
- this._textWrapper.removePart(deletePosition - 1, deletePosition);
510
- this._textHasChanged();
511
- }
512
- }
513
- }
514
- if (evt) {
515
- evt.preventDefault();
516
- }
517
- return;
518
- case 46: // DELETE
519
- if (this._isTextHighlightOn) {
520
- this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
521
- this._textHasChanged();
522
- this._isTextHighlightOn = false;
523
- this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
524
- if (evt) {
525
- evt.preventDefault();
526
- }
527
- return;
528
- }
529
- if (this._textWrapper.text && this._textWrapper.length > 0 && this._cursorOffset > 0) {
530
- var deletePosition = this._textWrapper.length - this._cursorOffset;
531
- this._textWrapper.removePart(deletePosition, deletePosition + 1);
532
- this._textHasChanged();
533
- this._cursorOffset--;
534
- }
535
- if (evt) {
536
- evt.preventDefault();
537
- }
538
- return;
539
- case 13: // RETURN
540
- this._host.focusedControl = null;
541
- this._isTextHighlightOn = false;
542
- return;
543
- case 35: // END
544
- this._cursorOffset = 0;
545
- this._blinkIsEven = false;
546
- this._isTextHighlightOn = false;
547
- this._markAsDirty();
548
- return;
549
- case 36: // HOME
550
- this._cursorOffset = this._textWrapper.length;
551
- this._blinkIsEven = false;
552
- this._isTextHighlightOn = false;
553
- this._markAsDirty();
554
- return;
555
- case 37: // LEFT
556
- this._cursorOffset++;
557
- if (this._cursorOffset > this._textWrapper.length) {
558
- this._cursorOffset = this._textWrapper.length;
559
- }
560
- if (evt && evt.shiftKey) {
561
- // update the cursor
562
- this._blinkIsEven = false;
563
- // shift + ctrl/cmd + <-
564
- if (evt.ctrlKey || evt.metaKey) {
565
- if (!this._isTextHighlightOn) {
566
- if (this._textWrapper.length === this._cursorOffset) {
567
- return;
568
- }
569
- else {
570
- this._endHighlightIndex = this._textWrapper.length - this._cursorOffset + 1;
571
- }
572
- }
573
- this._startHighlightIndex = 0;
574
- this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
575
- this._cursorOffset = this._textWrapper.length;
576
- this._isTextHighlightOn = true;
577
- this._markAsDirty();
578
- return;
579
- }
580
- //store the starting point
581
- if (!this._isTextHighlightOn) {
582
- this._isTextHighlightOn = true;
583
- this._cursorIndex = this._cursorOffset >= this._textWrapper.length ? this._textWrapper.length : this._cursorOffset - 1;
584
- }
585
- //if text is already highlighted
586
- else if (this._cursorIndex === -1) {
587
- this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
588
- this._cursorOffset = this._startHighlightIndex === 0 ? this._textWrapper.length : this._textWrapper.length - this._startHighlightIndex + 1;
589
- }
590
- //set the highlight indexes
591
- if (this._cursorIndex < this._cursorOffset) {
592
- this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
593
- this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
594
- }
595
- else if (this._cursorIndex > this._cursorOffset) {
596
- this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
597
- this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
598
- }
599
- else {
600
- this._isTextHighlightOn = false;
601
- }
602
- this._markAsDirty();
603
- return;
604
- }
605
- if (this._isTextHighlightOn) {
606
- this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
607
- this._isTextHighlightOn = false;
608
- }
609
- if (evt && (evt.ctrlKey || evt.metaKey)) {
610
- this._cursorOffset = this._textWrapper.length;
611
- evt.preventDefault();
612
- }
613
- this._blinkIsEven = false;
614
- this._isTextHighlightOn = false;
615
- this._cursorIndex = -1;
616
- this._markAsDirty();
617
- return;
618
- case 39: // RIGHT
619
- this._cursorOffset--;
620
- if (this._cursorOffset < 0) {
621
- this._cursorOffset = 0;
622
- }
623
- if (evt && evt.shiftKey) {
624
- //update the cursor
625
- this._blinkIsEven = false;
626
- //shift + ctrl/cmd + ->
627
- if (evt.ctrlKey || evt.metaKey) {
628
- if (!this._isTextHighlightOn) {
629
- if (this._cursorOffset === 0) {
630
- return;
631
- }
632
- else {
633
- this._startHighlightIndex = this._textWrapper.length - this._cursorOffset - 1;
634
- }
635
- }
636
- this._endHighlightIndex = this._textWrapper.length;
637
- this._isTextHighlightOn = true;
638
- this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
639
- this._cursorOffset = 0;
640
- this._markAsDirty();
641
- return;
642
- }
643
- if (!this._isTextHighlightOn) {
644
- this._isTextHighlightOn = true;
645
- this._cursorIndex = this._cursorOffset <= 0 ? 0 : this._cursorOffset + 1;
646
- }
647
- //if text is already highlighted
648
- else if (this._cursorIndex === -1) {
649
- this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
650
- this._cursorOffset = this._textWrapper.length === this._endHighlightIndex ? 0 : this._textWrapper.length - this._endHighlightIndex - 1;
651
- }
652
- //set the highlight indexes
653
- if (this._cursorIndex < this._cursorOffset) {
654
- this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
655
- this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
656
- }
657
- else if (this._cursorIndex > this._cursorOffset) {
658
- this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
659
- this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
660
- }
661
- else {
662
- this._isTextHighlightOn = false;
663
- }
664
- this._markAsDirty();
665
- return;
666
- }
667
- if (this._isTextHighlightOn) {
668
- this._cursorOffset = this._textWrapper.length - this._endHighlightIndex;
669
- this._isTextHighlightOn = false;
670
- }
671
- //ctr + ->
672
- if (evt && (evt.ctrlKey || evt.metaKey)) {
673
- this._cursorOffset = 0;
674
- evt.preventDefault();
675
- }
676
- this._blinkIsEven = false;
677
- this._isTextHighlightOn = false;
678
- this._cursorIndex = -1;
679
- this._markAsDirty();
680
- return;
681
- case 222: // Dead
682
- if (evt) {
683
- //add support for single and double quotes
684
- if (evt.code == "Quote") {
685
- if (evt.shiftKey) {
686
- keyCode = 34;
687
- key = '"';
688
- }
689
- else {
690
- keyCode = 39;
691
- key = "'";
692
- }
693
- }
694
- else {
695
- evt.preventDefault();
696
- this._cursorIndex = -1;
697
- this.deadKey = true;
698
- }
699
- }
700
- else {
701
- this._cursorIndex = -1;
702
- this.deadKey = true;
703
- }
704
- break;
705
- }
706
- // Printable characters
707
- if (key &&
708
- (keyCode === -1 || // Direct access
709
- keyCode === 32 || // Space
710
- keyCode === 34 || // " add support for single and double quotes
711
- keyCode === 39 || // '
712
- (keyCode > 47 && keyCode < 64) || // Numbers
713
- (keyCode > 64 && keyCode < 91) || // Letters
714
- (keyCode > 159 && keyCode < 193) || // Special characters
715
- (keyCode > 218 && keyCode < 223) || // Special characters
716
- (keyCode > 95 && keyCode < 112))) {
717
- // Numpad
718
- this._currentKey = key;
719
- this.onBeforeKeyAddObservable.notifyObservers(this);
720
- key = this._currentKey;
721
- if (this._addKey) {
722
- if (this._isTextHighlightOn) {
723
- this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex, key);
724
- this._textHasChanged();
725
- this._cursorOffset = this._textWrapper.length - (this._startHighlightIndex + 1);
726
- this._isTextHighlightOn = false;
727
- this._blinkIsEven = false;
728
- this._markAsDirty();
729
- }
730
- else if (this._cursorOffset === 0) {
731
- this.text += key;
732
- }
733
- else {
734
- var insertPosition = this._textWrapper.length - this._cursorOffset;
735
- this._textWrapper.removePart(insertPosition, insertPosition, key);
736
- this._textHasChanged();
737
- }
738
- }
739
- }
740
- };
741
- /**
742
- * @param offset
743
- * @hidden
744
- */
745
- InputText.prototype._updateValueFromCursorIndex = function (offset) {
746
- //update the cursor
747
- this._blinkIsEven = false;
748
- if (this._cursorIndex === -1) {
749
- this._cursorIndex = offset;
750
- }
751
- else {
752
- if (this._cursorIndex < this._cursorOffset) {
753
- this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
754
- this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
755
- }
756
- else if (this._cursorIndex > this._cursorOffset) {
757
- this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
758
- this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
759
- }
760
- else {
761
- this._isTextHighlightOn = false;
762
- this._markAsDirty();
763
- return;
764
- }
765
- }
766
- this._isTextHighlightOn = true;
767
- this._markAsDirty();
768
- };
769
- /**
770
- * @param evt
771
- * @hidden
772
- */
773
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
774
- InputText.prototype._processDblClick = function (evt) {
775
- //pre-find the start and end index of the word under cursor, speeds up the rendering
776
- this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
777
- this._endHighlightIndex = this._startHighlightIndex;
778
- var moveLeft, moveRight;
779
- do {
780
- moveRight = this._endHighlightIndex < this._textWrapper.length && this._textWrapper.isWord(this._endHighlightIndex) ? ++this._endHighlightIndex : 0;
781
- moveLeft = this._startHighlightIndex > 0 && this._textWrapper.isWord(this._startHighlightIndex - 1) ? --this._startHighlightIndex : 0;
782
- } while (moveLeft || moveRight);
783
- this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
784
- this.onTextHighlightObservable.notifyObservers(this);
785
- this._isTextHighlightOn = true;
786
- this._clickedCoordinate = null;
787
- this._blinkIsEven = true;
788
- this._cursorIndex = -1;
789
- this._markAsDirty();
790
- };
791
- /** @hidden */
792
- InputText.prototype._selectAllText = function () {
793
- this._blinkIsEven = true;
794
- this._isTextHighlightOn = true;
795
- this._startHighlightIndex = 0;
796
- this._endHighlightIndex = this._textWrapper.length;
797
- this._cursorOffset = this._textWrapper.length;
798
- this._cursorIndex = -1;
799
- this._markAsDirty();
800
- };
801
- /**
802
- * Handles the keyboard event
803
- * @param evt Defines the KeyboardEvent
804
- */
805
- InputText.prototype.processKeyboard = function (evt) {
806
- // process pressed key
807
- this.processKey(evt.keyCode, evt.key, evt);
808
- this.onKeyboardEventProcessedObservable.notifyObservers(evt);
809
- };
810
- /**
811
- * @param ev
812
- * @hidden
813
- */
814
- InputText.prototype._onCopyText = function (ev) {
815
- this._isTextHighlightOn = false;
816
- //when write permission to clipbaord data is denied
817
- try {
818
- ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
819
- }
820
- catch (_a) { } //pass
821
- this._host.clipboardData = this._highlightedText;
822
- };
823
- /**
824
- * @param ev
825
- * @hidden
826
- */
827
- InputText.prototype._onCutText = function (ev) {
828
- if (!this._highlightedText) {
829
- return;
830
- }
831
- this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
832
- this._textHasChanged();
833
- this._isTextHighlightOn = false;
834
- this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
835
- //when write permission to clipbaord data is denied
836
- try {
837
- ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
838
- }
839
- catch (_a) { } //pass
840
- this._host.clipboardData = this._highlightedText;
841
- this._highlightedText = "";
842
- };
843
- /**
844
- * @param ev
845
- * @hidden
846
- */
847
- InputText.prototype._onPasteText = function (ev) {
848
- var data = "";
849
- if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
850
- data = ev.clipboardData.getData("text/plain");
851
- }
852
- else {
853
- //get the cached data; returns blank string by default
854
- data = this._host.clipboardData;
855
- }
856
- var insertPosition = this._textWrapper.length - this._cursorOffset;
857
- this._textWrapper.removePart(insertPosition, insertPosition, data);
858
- this._textHasChanged();
859
- };
860
- InputText.prototype._draw = function (context) {
861
- var _this = this;
862
- context.save();
863
- this._applyStates(context);
864
- if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
865
- context.shadowColor = this.shadowColor;
866
- context.shadowBlur = this.shadowBlur;
867
- context.shadowOffsetX = this.shadowOffsetX;
868
- context.shadowOffsetY = this.shadowOffsetY;
869
- }
870
- // Background
871
- if (this._isFocused) {
872
- if (this._focusedBackground) {
873
- context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
874
- context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
875
- }
876
- }
877
- else if (this._background) {
878
- context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
879
- context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
880
- }
881
- if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
882
- context.shadowBlur = 0;
883
- context.shadowOffsetX = 0;
884
- context.shadowOffsetY = 0;
885
- }
886
- if (!this._fontOffset || this._wasDirty) {
887
- this._fontOffset = Control._GetFontOffset(context.font);
888
- }
889
- // Text
890
- var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
891
- if (this.color) {
892
- context.fillStyle = this.color;
893
- }
894
- var text = this._beforeRenderText(this._textWrapper);
895
- if (!this._isFocused && !this._textWrapper.text && this._placeholderText) {
896
- text = new TextWrapper();
897
- text.text = this._placeholderText;
898
- if (this._placeholderColor) {
899
- context.fillStyle = this._placeholderColor;
900
- }
901
- }
902
- this._textWidth = context.measureText(text.text).width;
903
- var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
904
- if (this._autoStretchWidth) {
905
- this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
906
- this._autoStretchWidth = true; // setting the width will have reset _autoStretchWidth to false!
907
- }
908
- var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
909
- var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
910
- context.save();
911
- context.beginPath();
912
- context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
913
- context.clip();
914
- if (this._isFocused && this._textWidth > availableWidth) {
915
- var textLeft = clipTextLeft - this._textWidth + availableWidth;
916
- if (!this._scrollLeft) {
917
- this._scrollLeft = textLeft;
918
- }
919
- }
920
- else {
921
- this._scrollLeft = clipTextLeft;
922
- }
923
- context.fillText(text.text, this._scrollLeft, this._currentMeasure.top + rootY);
924
- // Cursor
925
- if (this._isFocused) {
926
- // Need to move cursor
927
- if (this._clickedCoordinate) {
928
- var rightPosition = this._scrollLeft + this._textWidth;
929
- var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
930
- var currentSize = 0;
931
- this._cursorOffset = 0;
932
- var previousDist = 0;
933
- do {
934
- if (this._cursorOffset) {
935
- previousDist = Math.abs(absoluteCursorPosition - currentSize);
936
- }
937
- this._cursorOffset++;
938
- currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
939
- } while (currentSize < absoluteCursorPosition && text.length >= this._cursorOffset);
940
- // Find closest move
941
- if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
942
- this._cursorOffset--;
943
- }
944
- this._blinkIsEven = false;
945
- this._clickedCoordinate = null;
946
- }
947
- // Render cursor
948
- if (!this._blinkIsEven) {
949
- var cursorOffsetText = text.substr(text.length - this._cursorOffset);
950
- var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
951
- var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
952
- if (cursorLeft < clipTextLeft) {
953
- this._scrollLeft += clipTextLeft - cursorLeft;
954
- cursorLeft = clipTextLeft;
955
- this._markAsDirty();
956
- }
957
- else if (cursorLeft > clipTextLeft + availableWidth) {
958
- this._scrollLeft += clipTextLeft + availableWidth - cursorLeft;
959
- cursorLeft = clipTextLeft + availableWidth;
960
- this._markAsDirty();
961
- }
962
- if (!this._isTextHighlightOn) {
963
- context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
964
- }
965
- }
966
- clearTimeout(this._blinkTimeout);
967
- this._blinkTimeout = setTimeout(function () {
968
- _this._blinkIsEven = !_this._blinkIsEven;
969
- _this._markAsDirty();
970
- }, 500);
971
- //show the highlighted text
972
- if (this._isTextHighlightOn) {
973
- clearTimeout(this._blinkTimeout);
974
- var highlightCursorOffsetWidth = context.measureText(text.substring(this._startHighlightIndex)).width;
975
- var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
976
- this._highlightedText = text.substring(this._startHighlightIndex, this._endHighlightIndex);
977
- var width = context.measureText(text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
978
- if (highlightCursorLeft < clipTextLeft) {
979
- width = width - (clipTextLeft - highlightCursorLeft);
980
- if (!width) {
981
- // when using left arrow on text.length > availableWidth;
982
- // assigns the width of the first letter after clipTextLeft
983
- width = context.measureText(text.charAt(text.length - this._cursorOffset)).width;
984
- }
985
- highlightCursorLeft = clipTextLeft;
986
- }
987
- //for transparancy
988
- context.globalAlpha = this._highligherOpacity;
989
- context.fillStyle = this._textHighlightColor;
990
- context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
991
- context.globalAlpha = 1.0;
992
- }
993
- }
994
- context.restore();
995
- // Border
996
- if (this._thickness) {
997
- if (this._isFocused) {
998
- if (this.focusedColor) {
999
- context.strokeStyle = this.focusedColor;
1000
- }
1001
- }
1002
- else {
1003
- if (this.color) {
1004
- context.strokeStyle = this.color;
1005
- }
1006
- }
1007
- context.lineWidth = this._thickness;
1008
- context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
1009
- }
1010
- context.restore();
1011
- };
1012
- InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
1013
- if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
1014
- return false;
1015
- }
1016
- if (this.isReadOnly) {
1017
- return true;
1018
- }
1019
- this._clickedCoordinate = coordinates.x;
1020
- this._isTextHighlightOn = false;
1021
- this._highlightedText = "";
1022
- this._cursorIndex = -1;
1023
- this._isPointerDown = true;
1024
- this._host._capturingControl[pointerId] = this;
1025
- this._focusedBy = pi.event.pointerType;
1026
- if (this._host.focusedControl === this) {
1027
- // Move cursor
1028
- clearTimeout(this._blinkTimeout);
1029
- this._markAsDirty();
1030
- return true;
1031
- }
1032
- if (!this._isEnabled) {
1033
- return false;
1034
- }
1035
- this._host.focusedControl = this;
1036
- return true;
1037
- };
1038
- InputText.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
1039
- if (this._host.focusedControl === this && this._isPointerDown && !this.isReadOnly) {
1040
- this._clickedCoordinate = coordinates.x;
1041
- this._markAsDirty();
1042
- this._updateValueFromCursorIndex(this._cursorOffset);
1043
- }
1044
- _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
1045
- };
1046
- InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
1047
- this._isPointerDown = false;
1048
- delete this._host._capturingControl[pointerId];
1049
- _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
1050
- };
1051
- InputText.prototype._beforeRenderText = function (textWrapper) {
1052
- return textWrapper;
1053
- };
1054
- InputText.prototype.dispose = function () {
1055
- _super.prototype.dispose.call(this);
1056
- this.onBlurObservable.clear();
1057
- this.onFocusObservable.clear();
1058
- this.onTextChangedObservable.clear();
1059
- this.onTextCopyObservable.clear();
1060
- this.onTextCutObservable.clear();
1061
- this.onTextPasteObservable.clear();
1062
- this.onTextHighlightObservable.clear();
1063
- this.onKeyboardEventProcessedObservable.clear();
1064
- };
1065
- __decorate([
1066
- serialize()
1067
- ], InputText.prototype, "promptMessage", void 0);
1068
- __decorate([
1069
- serialize()
1070
- ], InputText.prototype, "disableMobilePrompt", void 0);
1071
- __decorate([
1072
- serialize()
1073
- ], InputText.prototype, "maxWidth", null);
1074
- __decorate([
1075
- serialize()
1076
- ], InputText.prototype, "highligherOpacity", null);
1077
- __decorate([
1078
- serialize()
1079
- ], InputText.prototype, "onFocusSelectAll", null);
1080
- __decorate([
1081
- serialize()
1082
- ], InputText.prototype, "textHighlightColor", null);
1083
- __decorate([
1084
- serialize()
1085
- ], InputText.prototype, "margin", null);
1086
- __decorate([
1087
- serialize()
1088
- ], InputText.prototype, "autoStretchWidth", null);
1089
- __decorate([
1090
- serialize()
1091
- ], InputText.prototype, "thickness", null);
1092
- __decorate([
1093
- serialize()
1094
- ], InputText.prototype, "focusedBackground", null);
1095
- __decorate([
1096
- serialize()
1097
- ], InputText.prototype, "focusedColor", null);
1098
- __decorate([
1099
- serialize()
1100
- ], InputText.prototype, "background", null);
1101
- __decorate([
1102
- serialize()
1103
- ], InputText.prototype, "placeholderColor", null);
1104
- __decorate([
1105
- serialize()
1106
- ], InputText.prototype, "placeholderText", null);
1107
- __decorate([
1108
- serialize()
1109
- ], InputText.prototype, "deadKey", null);
1110
- __decorate([
1111
- serialize()
1112
- ], InputText.prototype, "text", null);
1113
- __decorate([
1114
- serialize()
1115
- ], InputText.prototype, "width", null);
1116
- return InputText;
1117
- }(Control));
1118
- export { InputText };
1119
- RegisterClass("BABYLON.GUI.InputText", InputText);
1
+ import { __decorate, __extends } from "tslib";
2
+ import { Observable } from "@babylonjs/core/Misc/observable.js";
3
+ import { ClipboardEventTypes } from "@babylonjs/core/Events/clipboardEvents.js";
4
+ import { PointerEventTypes } from "@babylonjs/core/Events/pointerEvents.js";
5
+ import { Control } from "./control";
6
+ import { ValueAndUnit } from "../valueAndUnit";
7
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
8
+ import { TextWrapper } from "./textWrapper";
9
+ import { serialize } from "@babylonjs/core/Misc/decorators.js";
10
+ /**
11
+ * Class used to create input text control
12
+ */
13
+ var InputText = /** @class */ (function (_super) {
14
+ __extends(InputText, _super);
15
+ /**
16
+ * Creates a new InputText
17
+ * @param name defines the control name
18
+ * @param text defines the text of the control
19
+ */
20
+ function InputText(name, text) {
21
+ if (text === void 0) { text = ""; }
22
+ var _this = _super.call(this, name) || this;
23
+ _this.name = name;
24
+ _this._placeholderText = "";
25
+ _this._background = "#222222";
26
+ _this._focusedBackground = "#000000";
27
+ _this._focusedColor = "white";
28
+ _this._placeholderColor = "gray";
29
+ _this._thickness = 1;
30
+ _this._margin = new ValueAndUnit(10, ValueAndUnit.UNITMODE_PIXEL);
31
+ _this._autoStretchWidth = true;
32
+ _this._maxWidth = new ValueAndUnit(1, ValueAndUnit.UNITMODE_PERCENTAGE, false);
33
+ _this._isFocused = false;
34
+ _this._blinkIsEven = false;
35
+ _this._cursorOffset = 0;
36
+ _this._deadKey = false;
37
+ _this._addKey = true;
38
+ _this._currentKey = "";
39
+ _this._isTextHighlightOn = false;
40
+ _this._textHighlightColor = "#d5e0ff";
41
+ _this._highligherOpacity = 0.4;
42
+ _this._highlightedText = "";
43
+ _this._startHighlightIndex = 0;
44
+ _this._endHighlightIndex = 0;
45
+ _this._cursorIndex = -1;
46
+ _this._onFocusSelectAll = false;
47
+ _this._isPointerDown = false;
48
+ /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
49
+ _this.promptMessage = "Please enter text:";
50
+ /** Force disable prompt on mobile device */
51
+ _this.disableMobilePrompt = false;
52
+ /** Observable raised when the text changes */
53
+ _this.onTextChangedObservable = new Observable();
54
+ /** Observable raised just before an entered character is to be added */
55
+ _this.onBeforeKeyAddObservable = new Observable();
56
+ /** Observable raised when the control gets the focus */
57
+ _this.onFocusObservable = new Observable();
58
+ /** Observable raised when the control loses the focus */
59
+ _this.onBlurObservable = new Observable();
60
+ /**Observable raised when the text is highlighted */
61
+ _this.onTextHighlightObservable = new Observable();
62
+ /**Observable raised when copy event is triggered */
63
+ _this.onTextCopyObservable = new Observable();
64
+ /** Observable raised when cut event is triggered */
65
+ _this.onTextCutObservable = new Observable();
66
+ /** Observable raised when paste event is triggered */
67
+ _this.onTextPasteObservable = new Observable();
68
+ /** Observable raised when a key event was processed */
69
+ _this.onKeyboardEventProcessedObservable = new Observable();
70
+ _this.text = text;
71
+ _this.isPointerBlocker = true;
72
+ return _this;
73
+ }
74
+ Object.defineProperty(InputText.prototype, "maxWidth", {
75
+ /** Gets or sets the maximum width allowed by the control */
76
+ get: function () {
77
+ return this._maxWidth.toString(this._host);
78
+ },
79
+ set: function (value) {
80
+ if (this._maxWidth.toString(this._host) === value) {
81
+ return;
82
+ }
83
+ if (this._maxWidth.fromString(value)) {
84
+ this._markAsDirty();
85
+ }
86
+ },
87
+ enumerable: false,
88
+ configurable: true
89
+ });
90
+ Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
91
+ /** Gets the maximum width allowed by the control in pixels */
92
+ get: function () {
93
+ return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
94
+ },
95
+ enumerable: false,
96
+ configurable: true
97
+ });
98
+ Object.defineProperty(InputText.prototype, "highligherOpacity", {
99
+ /** Gets or sets the text highlighter transparency; default: 0.4 */
100
+ get: function () {
101
+ return this._highligherOpacity;
102
+ },
103
+ set: function (value) {
104
+ if (this._highligherOpacity === value) {
105
+ return;
106
+ }
107
+ this._highligherOpacity = value;
108
+ this._markAsDirty();
109
+ },
110
+ enumerable: false,
111
+ configurable: true
112
+ });
113
+ Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
114
+ /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
115
+ get: function () {
116
+ return this._onFocusSelectAll;
117
+ },
118
+ set: function (value) {
119
+ if (this._onFocusSelectAll === value) {
120
+ return;
121
+ }
122
+ this._onFocusSelectAll = value;
123
+ this._markAsDirty();
124
+ },
125
+ enumerable: false,
126
+ configurable: true
127
+ });
128
+ Object.defineProperty(InputText.prototype, "textHighlightColor", {
129
+ /** Gets or sets the text hightlight color */
130
+ get: function () {
131
+ return this._textHighlightColor;
132
+ },
133
+ set: function (value) {
134
+ if (this._textHighlightColor === value) {
135
+ return;
136
+ }
137
+ this._textHighlightColor = value;
138
+ this._markAsDirty();
139
+ },
140
+ enumerable: false,
141
+ configurable: true
142
+ });
143
+ Object.defineProperty(InputText.prototype, "margin", {
144
+ /** Gets or sets control margin */
145
+ get: function () {
146
+ return this._margin.toString(this._host);
147
+ },
148
+ set: function (value) {
149
+ if (this._margin.toString(this._host) === value) {
150
+ return;
151
+ }
152
+ if (this._margin.fromString(value)) {
153
+ this._markAsDirty();
154
+ }
155
+ },
156
+ enumerable: false,
157
+ configurable: true
158
+ });
159
+ Object.defineProperty(InputText.prototype, "marginInPixels", {
160
+ /** Gets control margin in pixels */
161
+ get: function () {
162
+ return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
163
+ },
164
+ enumerable: false,
165
+ configurable: true
166
+ });
167
+ Object.defineProperty(InputText.prototype, "autoStretchWidth", {
168
+ /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
169
+ get: function () {
170
+ return this._autoStretchWidth;
171
+ },
172
+ set: function (value) {
173
+ if (this._autoStretchWidth === value) {
174
+ return;
175
+ }
176
+ this._autoStretchWidth = value;
177
+ this._markAsDirty();
178
+ },
179
+ enumerable: false,
180
+ configurable: true
181
+ });
182
+ Object.defineProperty(InputText.prototype, "thickness", {
183
+ /** Gets or sets border thickness */
184
+ get: function () {
185
+ return this._thickness;
186
+ },
187
+ set: function (value) {
188
+ if (this._thickness === value) {
189
+ return;
190
+ }
191
+ this._thickness = value;
192
+ this._markAsDirty();
193
+ },
194
+ enumerable: false,
195
+ configurable: true
196
+ });
197
+ Object.defineProperty(InputText.prototype, "focusedBackground", {
198
+ /** Gets or sets the background color when focused */
199
+ get: function () {
200
+ return this._focusedBackground;
201
+ },
202
+ set: function (value) {
203
+ if (this._focusedBackground === value) {
204
+ return;
205
+ }
206
+ this._focusedBackground = value;
207
+ this._markAsDirty();
208
+ },
209
+ enumerable: false,
210
+ configurable: true
211
+ });
212
+ Object.defineProperty(InputText.prototype, "focusedColor", {
213
+ /** Gets or sets the background color when focused */
214
+ get: function () {
215
+ return this._focusedColor;
216
+ },
217
+ set: function (value) {
218
+ if (this._focusedColor === value) {
219
+ return;
220
+ }
221
+ this._focusedColor = value;
222
+ this._markAsDirty();
223
+ },
224
+ enumerable: false,
225
+ configurable: true
226
+ });
227
+ Object.defineProperty(InputText.prototype, "background", {
228
+ /** Gets or sets the background color */
229
+ get: function () {
230
+ return this._background;
231
+ },
232
+ set: function (value) {
233
+ if (this._background === value) {
234
+ return;
235
+ }
236
+ this._background = value;
237
+ this._markAsDirty();
238
+ },
239
+ enumerable: false,
240
+ configurable: true
241
+ });
242
+ Object.defineProperty(InputText.prototype, "placeholderColor", {
243
+ /** Gets or sets the placeholder color */
244
+ get: function () {
245
+ return this._placeholderColor;
246
+ },
247
+ set: function (value) {
248
+ if (this._placeholderColor === value) {
249
+ return;
250
+ }
251
+ this._placeholderColor = value;
252
+ this._markAsDirty();
253
+ },
254
+ enumerable: false,
255
+ configurable: true
256
+ });
257
+ Object.defineProperty(InputText.prototype, "placeholderText", {
258
+ /** Gets or sets the text displayed when the control is empty */
259
+ get: function () {
260
+ return this._placeholderText;
261
+ },
262
+ set: function (value) {
263
+ if (this._placeholderText === value) {
264
+ return;
265
+ }
266
+ this._placeholderText = value;
267
+ this._markAsDirty();
268
+ },
269
+ enumerable: false,
270
+ configurable: true
271
+ });
272
+ Object.defineProperty(InputText.prototype, "deadKey", {
273
+ /** Gets or sets the dead key flag */
274
+ get: function () {
275
+ return this._deadKey;
276
+ },
277
+ set: function (flag) {
278
+ this._deadKey = flag;
279
+ },
280
+ enumerable: false,
281
+ configurable: true
282
+ });
283
+ Object.defineProperty(InputText.prototype, "highlightedText", {
284
+ /** Gets or sets the highlight text */
285
+ get: function () {
286
+ return this._highlightedText;
287
+ },
288
+ set: function (text) {
289
+ if (this._highlightedText === text) {
290
+ return;
291
+ }
292
+ this._highlightedText = text;
293
+ this._markAsDirty();
294
+ },
295
+ enumerable: false,
296
+ configurable: true
297
+ });
298
+ Object.defineProperty(InputText.prototype, "addKey", {
299
+ /** Gets or sets if the current key should be added */
300
+ get: function () {
301
+ return this._addKey;
302
+ },
303
+ set: function (flag) {
304
+ this._addKey = flag;
305
+ },
306
+ enumerable: false,
307
+ configurable: true
308
+ });
309
+ Object.defineProperty(InputText.prototype, "currentKey", {
310
+ /** Gets or sets the value of the current key being entered */
311
+ get: function () {
312
+ return this._currentKey;
313
+ },
314
+ set: function (key) {
315
+ this._currentKey = key;
316
+ },
317
+ enumerable: false,
318
+ configurable: true
319
+ });
320
+ Object.defineProperty(InputText.prototype, "text", {
321
+ /** Gets or sets the text displayed in the control */
322
+ get: function () {
323
+ return this._textWrapper.text;
324
+ },
325
+ set: function (value) {
326
+ var valueAsString = value.toString(); // Forcing convertion
327
+ if (!this._textWrapper) {
328
+ this._textWrapper = new TextWrapper();
329
+ }
330
+ if (this._textWrapper.text === valueAsString) {
331
+ return;
332
+ }
333
+ this._textWrapper.text = valueAsString;
334
+ this._textHasChanged();
335
+ },
336
+ enumerable: false,
337
+ configurable: true
338
+ });
339
+ InputText.prototype._textHasChanged = function () {
340
+ this._markAsDirty();
341
+ this.onTextChangedObservable.notifyObservers(this);
342
+ };
343
+ Object.defineProperty(InputText.prototype, "width", {
344
+ /** Gets or sets control width */
345
+ get: function () {
346
+ return this._width.toString(this._host);
347
+ },
348
+ set: function (value) {
349
+ if (this._width.toString(this._host) === value) {
350
+ return;
351
+ }
352
+ if (this._width.fromString(value)) {
353
+ this._markAsDirty();
354
+ }
355
+ this.autoStretchWidth = false;
356
+ },
357
+ enumerable: false,
358
+ configurable: true
359
+ });
360
+ /** @hidden */
361
+ InputText.prototype.onBlur = function () {
362
+ this._isFocused = false;
363
+ this._scrollLeft = null;
364
+ this._cursorOffset = 0;
365
+ clearTimeout(this._blinkTimeout);
366
+ this._markAsDirty();
367
+ this.onBlurObservable.notifyObservers(this);
368
+ this._host.unRegisterClipboardEvents();
369
+ if (this._onClipboardObserver) {
370
+ this._host.onClipboardObservable.remove(this._onClipboardObserver);
371
+ }
372
+ var scene = this._host.getScene();
373
+ if (this._onPointerDblTapObserver && scene) {
374
+ scene.onPointerObservable.remove(this._onPointerDblTapObserver);
375
+ }
376
+ };
377
+ /** @hidden */
378
+ InputText.prototype.onFocus = function () {
379
+ var _this = this;
380
+ if (!this._isEnabled) {
381
+ return;
382
+ }
383
+ this._scrollLeft = null;
384
+ this._isFocused = true;
385
+ this._blinkIsEven = false;
386
+ this._cursorOffset = 0;
387
+ this._markAsDirty();
388
+ this.onFocusObservable.notifyObservers(this);
389
+ if (this._focusedBy === "touch" && !this.disableMobilePrompt) {
390
+ var value = prompt(this.promptMessage);
391
+ if (value !== null) {
392
+ this.text = value;
393
+ }
394
+ this._host.focusedControl = null;
395
+ return;
396
+ }
397
+ this._host.registerClipboardEvents();
398
+ this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
399
+ // process clipboard event, can be configured.
400
+ switch (clipboardInfo.type) {
401
+ case ClipboardEventTypes.COPY:
402
+ _this._onCopyText(clipboardInfo.event);
403
+ _this.onTextCopyObservable.notifyObservers(_this);
404
+ break;
405
+ case ClipboardEventTypes.CUT:
406
+ _this._onCutText(clipboardInfo.event);
407
+ _this.onTextCutObservable.notifyObservers(_this);
408
+ break;
409
+ case ClipboardEventTypes.PASTE:
410
+ _this._onPasteText(clipboardInfo.event);
411
+ _this.onTextPasteObservable.notifyObservers(_this);
412
+ break;
413
+ default:
414
+ return;
415
+ }
416
+ });
417
+ var scene = this._host.getScene();
418
+ if (scene) {
419
+ //register the pointer double tap event
420
+ this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
421
+ if (!_this._isFocused) {
422
+ return;
423
+ }
424
+ if (pointerInfo.type === PointerEventTypes.POINTERDOUBLETAP) {
425
+ _this._processDblClick(pointerInfo);
426
+ }
427
+ });
428
+ }
429
+ if (this._onFocusSelectAll) {
430
+ this._selectAllText();
431
+ }
432
+ };
433
+ /**
434
+ * Function to focus an inputText programmatically
435
+ */
436
+ InputText.prototype.focus = function () {
437
+ this._host.moveFocusToControl(this);
438
+ };
439
+ /**
440
+ * Function to unfocus an inputText programmatically
441
+ */
442
+ InputText.prototype.blur = function () {
443
+ this._host.focusedControl = null;
444
+ };
445
+ InputText.prototype._getTypeName = function () {
446
+ return "InputText";
447
+ };
448
+ /**
449
+ * Function called to get the list of controls that should not steal the focus from this control
450
+ * @returns an array of controls
451
+ */
452
+ InputText.prototype.keepsFocusWith = function () {
453
+ if (!this._connectedVirtualKeyboard) {
454
+ return null;
455
+ }
456
+ return [this._connectedVirtualKeyboard];
457
+ };
458
+ /**
459
+ * @param keyCode
460
+ * @param key
461
+ * @param evt
462
+ * @hidden
463
+ */
464
+ InputText.prototype.processKey = function (keyCode, key, evt) {
465
+ if (this.isReadOnly) {
466
+ return;
467
+ }
468
+ //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
469
+ if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
470
+ return;
471
+ }
472
+ //select all
473
+ if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
474
+ this._selectAllText();
475
+ evt.preventDefault();
476
+ return;
477
+ }
478
+ // Specific cases
479
+ switch (keyCode) {
480
+ case 32: //SPACE
481
+ key = " "; //ie11 key for space is "Spacebar"
482
+ break;
483
+ case 191: //SLASH
484
+ if (evt) {
485
+ evt.preventDefault();
486
+ }
487
+ break;
488
+ case 8: // BACKSPACE
489
+ if (this._textWrapper.text && this._textWrapper.length > 0) {
490
+ //delete the highlighted text
491
+ if (this._isTextHighlightOn) {
492
+ this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
493
+ this._textHasChanged();
494
+ this._isTextHighlightOn = false;
495
+ this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
496
+ this._blinkIsEven = false;
497
+ if (evt) {
498
+ evt.preventDefault();
499
+ }
500
+ return;
501
+ }
502
+ //delete single character
503
+ if (this._cursorOffset === 0) {
504
+ this.text = this._textWrapper.substr(0, this._textWrapper.length - 1);
505
+ }
506
+ else {
507
+ var deletePosition = this._textWrapper.length - this._cursorOffset;
508
+ if (deletePosition > 0) {
509
+ this._textWrapper.removePart(deletePosition - 1, deletePosition);
510
+ this._textHasChanged();
511
+ }
512
+ }
513
+ }
514
+ if (evt) {
515
+ evt.preventDefault();
516
+ }
517
+ return;
518
+ case 46: // DELETE
519
+ if (this._isTextHighlightOn) {
520
+ this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
521
+ this._textHasChanged();
522
+ this._isTextHighlightOn = false;
523
+ this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
524
+ if (evt) {
525
+ evt.preventDefault();
526
+ }
527
+ return;
528
+ }
529
+ if (this._textWrapper.text && this._textWrapper.length > 0 && this._cursorOffset > 0) {
530
+ var deletePosition = this._textWrapper.length - this._cursorOffset;
531
+ this._textWrapper.removePart(deletePosition, deletePosition + 1);
532
+ this._textHasChanged();
533
+ this._cursorOffset--;
534
+ }
535
+ if (evt) {
536
+ evt.preventDefault();
537
+ }
538
+ return;
539
+ case 13: // RETURN
540
+ this._host.focusedControl = null;
541
+ this._isTextHighlightOn = false;
542
+ return;
543
+ case 35: // END
544
+ this._cursorOffset = 0;
545
+ this._blinkIsEven = false;
546
+ this._isTextHighlightOn = false;
547
+ this._markAsDirty();
548
+ return;
549
+ case 36: // HOME
550
+ this._cursorOffset = this._textWrapper.length;
551
+ this._blinkIsEven = false;
552
+ this._isTextHighlightOn = false;
553
+ this._markAsDirty();
554
+ return;
555
+ case 37: // LEFT
556
+ this._cursorOffset++;
557
+ if (this._cursorOffset > this._textWrapper.length) {
558
+ this._cursorOffset = this._textWrapper.length;
559
+ }
560
+ if (evt && evt.shiftKey) {
561
+ // update the cursor
562
+ this._blinkIsEven = false;
563
+ // shift + ctrl/cmd + <-
564
+ if (evt.ctrlKey || evt.metaKey) {
565
+ if (!this._isTextHighlightOn) {
566
+ if (this._textWrapper.length === this._cursorOffset) {
567
+ return;
568
+ }
569
+ else {
570
+ this._endHighlightIndex = this._textWrapper.length - this._cursorOffset + 1;
571
+ }
572
+ }
573
+ this._startHighlightIndex = 0;
574
+ this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
575
+ this._cursorOffset = this._textWrapper.length;
576
+ this._isTextHighlightOn = true;
577
+ this._markAsDirty();
578
+ return;
579
+ }
580
+ //store the starting point
581
+ if (!this._isTextHighlightOn) {
582
+ this._isTextHighlightOn = true;
583
+ this._cursorIndex = this._cursorOffset >= this._textWrapper.length ? this._textWrapper.length : this._cursorOffset - 1;
584
+ }
585
+ //if text is already highlighted
586
+ else if (this._cursorIndex === -1) {
587
+ this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
588
+ this._cursorOffset = this._startHighlightIndex === 0 ? this._textWrapper.length : this._textWrapper.length - this._startHighlightIndex + 1;
589
+ }
590
+ //set the highlight indexes
591
+ if (this._cursorIndex < this._cursorOffset) {
592
+ this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
593
+ this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
594
+ }
595
+ else if (this._cursorIndex > this._cursorOffset) {
596
+ this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
597
+ this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
598
+ }
599
+ else {
600
+ this._isTextHighlightOn = false;
601
+ }
602
+ this._markAsDirty();
603
+ return;
604
+ }
605
+ if (this._isTextHighlightOn) {
606
+ this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
607
+ this._isTextHighlightOn = false;
608
+ }
609
+ if (evt && (evt.ctrlKey || evt.metaKey)) {
610
+ this._cursorOffset = this._textWrapper.length;
611
+ evt.preventDefault();
612
+ }
613
+ this._blinkIsEven = false;
614
+ this._isTextHighlightOn = false;
615
+ this._cursorIndex = -1;
616
+ this._markAsDirty();
617
+ return;
618
+ case 39: // RIGHT
619
+ this._cursorOffset--;
620
+ if (this._cursorOffset < 0) {
621
+ this._cursorOffset = 0;
622
+ }
623
+ if (evt && evt.shiftKey) {
624
+ //update the cursor
625
+ this._blinkIsEven = false;
626
+ //shift + ctrl/cmd + ->
627
+ if (evt.ctrlKey || evt.metaKey) {
628
+ if (!this._isTextHighlightOn) {
629
+ if (this._cursorOffset === 0) {
630
+ return;
631
+ }
632
+ else {
633
+ this._startHighlightIndex = this._textWrapper.length - this._cursorOffset - 1;
634
+ }
635
+ }
636
+ this._endHighlightIndex = this._textWrapper.length;
637
+ this._isTextHighlightOn = true;
638
+ this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
639
+ this._cursorOffset = 0;
640
+ this._markAsDirty();
641
+ return;
642
+ }
643
+ if (!this._isTextHighlightOn) {
644
+ this._isTextHighlightOn = true;
645
+ this._cursorIndex = this._cursorOffset <= 0 ? 0 : this._cursorOffset + 1;
646
+ }
647
+ //if text is already highlighted
648
+ else if (this._cursorIndex === -1) {
649
+ this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
650
+ this._cursorOffset = this._textWrapper.length === this._endHighlightIndex ? 0 : this._textWrapper.length - this._endHighlightIndex - 1;
651
+ }
652
+ //set the highlight indexes
653
+ if (this._cursorIndex < this._cursorOffset) {
654
+ this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
655
+ this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
656
+ }
657
+ else if (this._cursorIndex > this._cursorOffset) {
658
+ this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
659
+ this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
660
+ }
661
+ else {
662
+ this._isTextHighlightOn = false;
663
+ }
664
+ this._markAsDirty();
665
+ return;
666
+ }
667
+ if (this._isTextHighlightOn) {
668
+ this._cursorOffset = this._textWrapper.length - this._endHighlightIndex;
669
+ this._isTextHighlightOn = false;
670
+ }
671
+ //ctr + ->
672
+ if (evt && (evt.ctrlKey || evt.metaKey)) {
673
+ this._cursorOffset = 0;
674
+ evt.preventDefault();
675
+ }
676
+ this._blinkIsEven = false;
677
+ this._isTextHighlightOn = false;
678
+ this._cursorIndex = -1;
679
+ this._markAsDirty();
680
+ return;
681
+ case 222: // Dead
682
+ if (evt) {
683
+ //add support for single and double quotes
684
+ if (evt.code == "Quote") {
685
+ if (evt.shiftKey) {
686
+ keyCode = 34;
687
+ key = '"';
688
+ }
689
+ else {
690
+ keyCode = 39;
691
+ key = "'";
692
+ }
693
+ }
694
+ else {
695
+ evt.preventDefault();
696
+ this._cursorIndex = -1;
697
+ this.deadKey = true;
698
+ }
699
+ }
700
+ else {
701
+ this._cursorIndex = -1;
702
+ this.deadKey = true;
703
+ }
704
+ break;
705
+ }
706
+ // Printable characters
707
+ if (key &&
708
+ (keyCode === -1 || // Direct access
709
+ keyCode === 32 || // Space
710
+ keyCode === 34 || // " add support for single and double quotes
711
+ keyCode === 39 || // '
712
+ (keyCode > 47 && keyCode < 64) || // Numbers
713
+ (keyCode > 64 && keyCode < 91) || // Letters
714
+ (keyCode > 159 && keyCode < 193) || // Special characters
715
+ (keyCode > 218 && keyCode < 223) || // Special characters
716
+ (keyCode > 95 && keyCode < 112))) {
717
+ // Numpad
718
+ this._currentKey = key;
719
+ this.onBeforeKeyAddObservable.notifyObservers(this);
720
+ key = this._currentKey;
721
+ if (this._addKey) {
722
+ if (this._isTextHighlightOn) {
723
+ this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex, key);
724
+ this._textHasChanged();
725
+ this._cursorOffset = this._textWrapper.length - (this._startHighlightIndex + 1);
726
+ this._isTextHighlightOn = false;
727
+ this._blinkIsEven = false;
728
+ this._markAsDirty();
729
+ }
730
+ else if (this._cursorOffset === 0) {
731
+ this.text += key;
732
+ }
733
+ else {
734
+ var insertPosition = this._textWrapper.length - this._cursorOffset;
735
+ this._textWrapper.removePart(insertPosition, insertPosition, key);
736
+ this._textHasChanged();
737
+ }
738
+ }
739
+ }
740
+ };
741
+ /**
742
+ * @param offset
743
+ * @hidden
744
+ */
745
+ InputText.prototype._updateValueFromCursorIndex = function (offset) {
746
+ //update the cursor
747
+ this._blinkIsEven = false;
748
+ if (this._cursorIndex === -1) {
749
+ this._cursorIndex = offset;
750
+ }
751
+ else {
752
+ if (this._cursorIndex < this._cursorOffset) {
753
+ this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
754
+ this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
755
+ }
756
+ else if (this._cursorIndex > this._cursorOffset) {
757
+ this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
758
+ this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
759
+ }
760
+ else {
761
+ this._isTextHighlightOn = false;
762
+ this._markAsDirty();
763
+ return;
764
+ }
765
+ }
766
+ this._isTextHighlightOn = true;
767
+ this._markAsDirty();
768
+ };
769
+ /**
770
+ * @param evt
771
+ * @hidden
772
+ */
773
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
774
+ InputText.prototype._processDblClick = function (evt) {
775
+ //pre-find the start and end index of the word under cursor, speeds up the rendering
776
+ this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
777
+ this._endHighlightIndex = this._startHighlightIndex;
778
+ var moveLeft, moveRight;
779
+ do {
780
+ moveRight = this._endHighlightIndex < this._textWrapper.length && this._textWrapper.isWord(this._endHighlightIndex) ? ++this._endHighlightIndex : 0;
781
+ moveLeft = this._startHighlightIndex > 0 && this._textWrapper.isWord(this._startHighlightIndex - 1) ? --this._startHighlightIndex : 0;
782
+ } while (moveLeft || moveRight);
783
+ this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
784
+ this.onTextHighlightObservable.notifyObservers(this);
785
+ this._isTextHighlightOn = true;
786
+ this._clickedCoordinate = null;
787
+ this._blinkIsEven = true;
788
+ this._cursorIndex = -1;
789
+ this._markAsDirty();
790
+ };
791
+ /** @hidden */
792
+ InputText.prototype._selectAllText = function () {
793
+ this._blinkIsEven = true;
794
+ this._isTextHighlightOn = true;
795
+ this._startHighlightIndex = 0;
796
+ this._endHighlightIndex = this._textWrapper.length;
797
+ this._cursorOffset = this._textWrapper.length;
798
+ this._cursorIndex = -1;
799
+ this._markAsDirty();
800
+ };
801
+ /**
802
+ * Handles the keyboard event
803
+ * @param evt Defines the KeyboardEvent
804
+ */
805
+ InputText.prototype.processKeyboard = function (evt) {
806
+ // process pressed key
807
+ this.processKey(evt.keyCode, evt.key, evt);
808
+ this.onKeyboardEventProcessedObservable.notifyObservers(evt);
809
+ };
810
+ /**
811
+ * @param ev
812
+ * @hidden
813
+ */
814
+ InputText.prototype._onCopyText = function (ev) {
815
+ this._isTextHighlightOn = false;
816
+ //when write permission to clipbaord data is denied
817
+ try {
818
+ ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
819
+ }
820
+ catch (_a) { } //pass
821
+ this._host.clipboardData = this._highlightedText;
822
+ };
823
+ /**
824
+ * @param ev
825
+ * @hidden
826
+ */
827
+ InputText.prototype._onCutText = function (ev) {
828
+ if (!this._highlightedText) {
829
+ return;
830
+ }
831
+ this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
832
+ this._textHasChanged();
833
+ this._isTextHighlightOn = false;
834
+ this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
835
+ //when write permission to clipbaord data is denied
836
+ try {
837
+ ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
838
+ }
839
+ catch (_a) { } //pass
840
+ this._host.clipboardData = this._highlightedText;
841
+ this._highlightedText = "";
842
+ };
843
+ /**
844
+ * @param ev
845
+ * @hidden
846
+ */
847
+ InputText.prototype._onPasteText = function (ev) {
848
+ var data = "";
849
+ if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
850
+ data = ev.clipboardData.getData("text/plain");
851
+ }
852
+ else {
853
+ //get the cached data; returns blank string by default
854
+ data = this._host.clipboardData;
855
+ }
856
+ var insertPosition = this._textWrapper.length - this._cursorOffset;
857
+ this._textWrapper.removePart(insertPosition, insertPosition, data);
858
+ this._textHasChanged();
859
+ };
860
+ InputText.prototype._draw = function (context) {
861
+ var _this = this;
862
+ context.save();
863
+ this._applyStates(context);
864
+ if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
865
+ context.shadowColor = this.shadowColor;
866
+ context.shadowBlur = this.shadowBlur;
867
+ context.shadowOffsetX = this.shadowOffsetX;
868
+ context.shadowOffsetY = this.shadowOffsetY;
869
+ }
870
+ // Background
871
+ if (this._isFocused) {
872
+ if (this._focusedBackground) {
873
+ context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
874
+ context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
875
+ }
876
+ }
877
+ else if (this._background) {
878
+ context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
879
+ context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
880
+ }
881
+ if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
882
+ context.shadowBlur = 0;
883
+ context.shadowOffsetX = 0;
884
+ context.shadowOffsetY = 0;
885
+ }
886
+ if (!this._fontOffset || this._wasDirty) {
887
+ this._fontOffset = Control._GetFontOffset(context.font);
888
+ }
889
+ // Text
890
+ var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
891
+ if (this.color) {
892
+ context.fillStyle = this.color;
893
+ }
894
+ var text = this._beforeRenderText(this._textWrapper);
895
+ if (!this._isFocused && !this._textWrapper.text && this._placeholderText) {
896
+ text = new TextWrapper();
897
+ text.text = this._placeholderText;
898
+ if (this._placeholderColor) {
899
+ context.fillStyle = this._placeholderColor;
900
+ }
901
+ }
902
+ this._textWidth = context.measureText(text.text).width;
903
+ var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
904
+ if (this._autoStretchWidth) {
905
+ this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
906
+ this._autoStretchWidth = true; // setting the width will have reset _autoStretchWidth to false!
907
+ }
908
+ var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
909
+ var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
910
+ context.save();
911
+ context.beginPath();
912
+ context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
913
+ context.clip();
914
+ if (this._isFocused && this._textWidth > availableWidth) {
915
+ var textLeft = clipTextLeft - this._textWidth + availableWidth;
916
+ if (!this._scrollLeft) {
917
+ this._scrollLeft = textLeft;
918
+ }
919
+ }
920
+ else {
921
+ this._scrollLeft = clipTextLeft;
922
+ }
923
+ context.fillText(text.text, this._scrollLeft, this._currentMeasure.top + rootY);
924
+ // Cursor
925
+ if (this._isFocused) {
926
+ // Need to move cursor
927
+ if (this._clickedCoordinate) {
928
+ var rightPosition = this._scrollLeft + this._textWidth;
929
+ var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
930
+ var currentSize = 0;
931
+ this._cursorOffset = 0;
932
+ var previousDist = 0;
933
+ do {
934
+ if (this._cursorOffset) {
935
+ previousDist = Math.abs(absoluteCursorPosition - currentSize);
936
+ }
937
+ this._cursorOffset++;
938
+ currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
939
+ } while (currentSize < absoluteCursorPosition && text.length >= this._cursorOffset);
940
+ // Find closest move
941
+ if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
942
+ this._cursorOffset--;
943
+ }
944
+ this._blinkIsEven = false;
945
+ this._clickedCoordinate = null;
946
+ }
947
+ // Render cursor
948
+ if (!this._blinkIsEven) {
949
+ var cursorOffsetText = text.substr(text.length - this._cursorOffset);
950
+ var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
951
+ var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
952
+ if (cursorLeft < clipTextLeft) {
953
+ this._scrollLeft += clipTextLeft - cursorLeft;
954
+ cursorLeft = clipTextLeft;
955
+ this._markAsDirty();
956
+ }
957
+ else if (cursorLeft > clipTextLeft + availableWidth) {
958
+ this._scrollLeft += clipTextLeft + availableWidth - cursorLeft;
959
+ cursorLeft = clipTextLeft + availableWidth;
960
+ this._markAsDirty();
961
+ }
962
+ if (!this._isTextHighlightOn) {
963
+ context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
964
+ }
965
+ }
966
+ clearTimeout(this._blinkTimeout);
967
+ this._blinkTimeout = setTimeout(function () {
968
+ _this._blinkIsEven = !_this._blinkIsEven;
969
+ _this._markAsDirty();
970
+ }, 500);
971
+ //show the highlighted text
972
+ if (this._isTextHighlightOn) {
973
+ clearTimeout(this._blinkTimeout);
974
+ var highlightCursorOffsetWidth = context.measureText(text.substring(this._startHighlightIndex)).width;
975
+ var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
976
+ this._highlightedText = text.substring(this._startHighlightIndex, this._endHighlightIndex);
977
+ var width = context.measureText(text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
978
+ if (highlightCursorLeft < clipTextLeft) {
979
+ width = width - (clipTextLeft - highlightCursorLeft);
980
+ if (!width) {
981
+ // when using left arrow on text.length > availableWidth;
982
+ // assigns the width of the first letter after clipTextLeft
983
+ width = context.measureText(text.charAt(text.length - this._cursorOffset)).width;
984
+ }
985
+ highlightCursorLeft = clipTextLeft;
986
+ }
987
+ //for transparancy
988
+ context.globalAlpha = this._highligherOpacity;
989
+ context.fillStyle = this._textHighlightColor;
990
+ context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
991
+ context.globalAlpha = 1.0;
992
+ }
993
+ }
994
+ context.restore();
995
+ // Border
996
+ if (this._thickness) {
997
+ if (this._isFocused) {
998
+ if (this.focusedColor) {
999
+ context.strokeStyle = this.focusedColor;
1000
+ }
1001
+ }
1002
+ else {
1003
+ if (this.color) {
1004
+ context.strokeStyle = this.color;
1005
+ }
1006
+ }
1007
+ context.lineWidth = this._thickness;
1008
+ context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
1009
+ }
1010
+ context.restore();
1011
+ };
1012
+ InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
1013
+ if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
1014
+ return false;
1015
+ }
1016
+ if (this.isReadOnly) {
1017
+ return true;
1018
+ }
1019
+ this._clickedCoordinate = coordinates.x;
1020
+ this._isTextHighlightOn = false;
1021
+ this._highlightedText = "";
1022
+ this._cursorIndex = -1;
1023
+ this._isPointerDown = true;
1024
+ this._host._capturingControl[pointerId] = this;
1025
+ this._focusedBy = pi.event.pointerType;
1026
+ if (this._host.focusedControl === this) {
1027
+ // Move cursor
1028
+ clearTimeout(this._blinkTimeout);
1029
+ this._markAsDirty();
1030
+ return true;
1031
+ }
1032
+ if (!this._isEnabled) {
1033
+ return false;
1034
+ }
1035
+ this._host.focusedControl = this;
1036
+ return true;
1037
+ };
1038
+ InputText.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
1039
+ if (this._host.focusedControl === this && this._isPointerDown && !this.isReadOnly) {
1040
+ this._clickedCoordinate = coordinates.x;
1041
+ this._markAsDirty();
1042
+ this._updateValueFromCursorIndex(this._cursorOffset);
1043
+ }
1044
+ _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
1045
+ };
1046
+ InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
1047
+ this._isPointerDown = false;
1048
+ delete this._host._capturingControl[pointerId];
1049
+ _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
1050
+ };
1051
+ InputText.prototype._beforeRenderText = function (textWrapper) {
1052
+ return textWrapper;
1053
+ };
1054
+ InputText.prototype.dispose = function () {
1055
+ _super.prototype.dispose.call(this);
1056
+ this.onBlurObservable.clear();
1057
+ this.onFocusObservable.clear();
1058
+ this.onTextChangedObservable.clear();
1059
+ this.onTextCopyObservable.clear();
1060
+ this.onTextCutObservable.clear();
1061
+ this.onTextPasteObservable.clear();
1062
+ this.onTextHighlightObservable.clear();
1063
+ this.onKeyboardEventProcessedObservable.clear();
1064
+ };
1065
+ __decorate([
1066
+ serialize()
1067
+ ], InputText.prototype, "promptMessage", void 0);
1068
+ __decorate([
1069
+ serialize()
1070
+ ], InputText.prototype, "disableMobilePrompt", void 0);
1071
+ __decorate([
1072
+ serialize()
1073
+ ], InputText.prototype, "maxWidth", null);
1074
+ __decorate([
1075
+ serialize()
1076
+ ], InputText.prototype, "highligherOpacity", null);
1077
+ __decorate([
1078
+ serialize()
1079
+ ], InputText.prototype, "onFocusSelectAll", null);
1080
+ __decorate([
1081
+ serialize()
1082
+ ], InputText.prototype, "textHighlightColor", null);
1083
+ __decorate([
1084
+ serialize()
1085
+ ], InputText.prototype, "margin", null);
1086
+ __decorate([
1087
+ serialize()
1088
+ ], InputText.prototype, "autoStretchWidth", null);
1089
+ __decorate([
1090
+ serialize()
1091
+ ], InputText.prototype, "thickness", null);
1092
+ __decorate([
1093
+ serialize()
1094
+ ], InputText.prototype, "focusedBackground", null);
1095
+ __decorate([
1096
+ serialize()
1097
+ ], InputText.prototype, "focusedColor", null);
1098
+ __decorate([
1099
+ serialize()
1100
+ ], InputText.prototype, "background", null);
1101
+ __decorate([
1102
+ serialize()
1103
+ ], InputText.prototype, "placeholderColor", null);
1104
+ __decorate([
1105
+ serialize()
1106
+ ], InputText.prototype, "placeholderText", null);
1107
+ __decorate([
1108
+ serialize()
1109
+ ], InputText.prototype, "deadKey", null);
1110
+ __decorate([
1111
+ serialize()
1112
+ ], InputText.prototype, "text", null);
1113
+ __decorate([
1114
+ serialize()
1115
+ ], InputText.prototype, "width", null);
1116
+ return InputText;
1117
+ }(Control));
1118
+ export { InputText };
1119
+ RegisterClass("BABYLON.GUI.InputText", InputText);
1120
1120
  //# sourceMappingURL=inputText.js.map