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