@babylonjs/gui 5.40.1 → 5.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2D/advancedDynamicTexture.js +3 -0
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/control.d.ts +2 -2
- package/2D/controls/control.js.map +1 -1
- package/2D/controls/image.d.ts +9 -0
- package/2D/controls/image.js +29 -0
- package/2D/controls/image.js.map +1 -1
- package/2D/controls/inputText.d.ts +4 -0
- package/2D/controls/inputText.js +48 -35
- package/2D/controls/inputText.js.map +1 -1
- package/2D/controls/inputTextArea.d.ts +2 -3
- package/2D/controls/inputTextArea.js +11 -11
- package/2D/controls/inputTextArea.js.map +1 -1
- package/2D/controls/line.d.ts +13 -6
- package/2D/controls/line.js +6 -0
- package/2D/controls/line.js.map +1 -1
- package/3D/controls/slider3D.js +4 -2
- package/3D/controls/slider3D.js.map +1 -1
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +3 -0
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -1
- package/package.json +2 -2
package/2D/controls/inputText.js
CHANGED
@@ -402,10 +402,10 @@ export class InputText extends Control {
|
|
402
402
|
case 8: // BACKSPACE
|
403
403
|
if (this._textWrapper.text && this._textWrapper.length > 0) {
|
404
404
|
//delete the highlighted text
|
405
|
-
if (this.
|
405
|
+
if (this.isTextHighlightOn) {
|
406
406
|
this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
|
407
407
|
this._textHasChanged();
|
408
|
-
this.
|
408
|
+
this.isTextHighlightOn = false;
|
409
409
|
this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
|
410
410
|
this._blinkIsEven = false;
|
411
411
|
if (evt) {
|
@@ -430,10 +430,10 @@ export class InputText extends Control {
|
|
430
430
|
}
|
431
431
|
return;
|
432
432
|
case 46: // DELETE
|
433
|
-
if (this.
|
433
|
+
if (this.isTextHighlightOn) {
|
434
434
|
this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
|
435
435
|
this._textHasChanged();
|
436
|
-
this.
|
436
|
+
this.isTextHighlightOn = false;
|
437
437
|
this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
|
438
438
|
if (evt) {
|
439
439
|
evt.preventDefault();
|
@@ -452,18 +452,18 @@ export class InputText extends Control {
|
|
452
452
|
return;
|
453
453
|
case 13: // RETURN
|
454
454
|
this._host.focusedControl = null;
|
455
|
-
this.
|
455
|
+
this.isTextHighlightOn = false;
|
456
456
|
return;
|
457
457
|
case 35: // END
|
458
458
|
this._cursorOffset = 0;
|
459
459
|
this._blinkIsEven = false;
|
460
|
-
this.
|
460
|
+
this.isTextHighlightOn = false;
|
461
461
|
this._markAsDirty();
|
462
462
|
return;
|
463
463
|
case 36: // HOME
|
464
464
|
this._cursorOffset = this._textWrapper.length;
|
465
465
|
this._blinkIsEven = false;
|
466
|
-
this.
|
466
|
+
this.isTextHighlightOn = false;
|
467
467
|
this._markAsDirty();
|
468
468
|
return;
|
469
469
|
case 37: // LEFT
|
@@ -476,7 +476,7 @@ export class InputText extends Control {
|
|
476
476
|
this._blinkIsEven = false;
|
477
477
|
// shift + ctrl/cmd + <-
|
478
478
|
if (evt.ctrlKey || evt.metaKey) {
|
479
|
-
if (!this.
|
479
|
+
if (!this.isTextHighlightOn) {
|
480
480
|
if (this._textWrapper.length === this._cursorOffset) {
|
481
481
|
return;
|
482
482
|
}
|
@@ -487,13 +487,13 @@ export class InputText extends Control {
|
|
487
487
|
this._startHighlightIndex = 0;
|
488
488
|
this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
|
489
489
|
this._cursorOffset = this._textWrapper.length;
|
490
|
-
this.
|
490
|
+
this.isTextHighlightOn = true;
|
491
491
|
this._markAsDirty();
|
492
492
|
return;
|
493
493
|
}
|
494
494
|
//store the starting point
|
495
|
-
if (!this.
|
496
|
-
this.
|
495
|
+
if (!this.isTextHighlightOn) {
|
496
|
+
this.isTextHighlightOn = true;
|
497
497
|
this._cursorIndex = this._cursorOffset >= this._textWrapper.length ? this._textWrapper.length : this._cursorOffset - 1;
|
498
498
|
}
|
499
499
|
//if text is already highlighted
|
@@ -511,21 +511,21 @@ export class InputText extends Control {
|
|
511
511
|
this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
|
512
512
|
}
|
513
513
|
else {
|
514
|
-
this.
|
514
|
+
this.isTextHighlightOn = false;
|
515
515
|
}
|
516
516
|
this._markAsDirty();
|
517
517
|
return;
|
518
518
|
}
|
519
|
-
if (this.
|
519
|
+
if (this.isTextHighlightOn) {
|
520
520
|
this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
|
521
|
-
this.
|
521
|
+
this.isTextHighlightOn = false;
|
522
522
|
}
|
523
523
|
if (evt && (evt.ctrlKey || evt.metaKey)) {
|
524
524
|
this._cursorOffset = this._textWrapper.length;
|
525
525
|
evt.preventDefault();
|
526
526
|
}
|
527
527
|
this._blinkIsEven = false;
|
528
|
-
this.
|
528
|
+
this.isTextHighlightOn = false;
|
529
529
|
this._cursorIndex = -1;
|
530
530
|
this._markAsDirty();
|
531
531
|
return;
|
@@ -539,7 +539,7 @@ export class InputText extends Control {
|
|
539
539
|
this._blinkIsEven = false;
|
540
540
|
//shift + ctrl/cmd + ->
|
541
541
|
if (evt.ctrlKey || evt.metaKey) {
|
542
|
-
if (!this.
|
542
|
+
if (!this.isTextHighlightOn) {
|
543
543
|
if (this._cursorOffset === 0) {
|
544
544
|
return;
|
545
545
|
}
|
@@ -548,14 +548,14 @@ export class InputText extends Control {
|
|
548
548
|
}
|
549
549
|
}
|
550
550
|
this._endHighlightIndex = this._textWrapper.length;
|
551
|
-
this.
|
551
|
+
this.isTextHighlightOn = true;
|
552
552
|
this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
|
553
553
|
this._cursorOffset = 0;
|
554
554
|
this._markAsDirty();
|
555
555
|
return;
|
556
556
|
}
|
557
|
-
if (!this.
|
558
|
-
this.
|
557
|
+
if (!this.isTextHighlightOn) {
|
558
|
+
this.isTextHighlightOn = true;
|
559
559
|
this._cursorIndex = this._cursorOffset <= 0 ? 0 : this._cursorOffset + 1;
|
560
560
|
}
|
561
561
|
//if text is already highlighted
|
@@ -573,14 +573,14 @@ export class InputText extends Control {
|
|
573
573
|
this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
|
574
574
|
}
|
575
575
|
else {
|
576
|
-
this.
|
576
|
+
this.isTextHighlightOn = false;
|
577
577
|
}
|
578
578
|
this._markAsDirty();
|
579
579
|
return;
|
580
580
|
}
|
581
|
-
if (this.
|
581
|
+
if (this.isTextHighlightOn) {
|
582
582
|
this._cursorOffset = this._textWrapper.length - this._endHighlightIndex;
|
583
|
-
this.
|
583
|
+
this.isTextHighlightOn = false;
|
584
584
|
}
|
585
585
|
//ctr + ->
|
586
586
|
if (evt && (evt.ctrlKey || evt.metaKey)) {
|
@@ -588,7 +588,7 @@ export class InputText extends Control {
|
|
588
588
|
evt.preventDefault();
|
589
589
|
}
|
590
590
|
this._blinkIsEven = false;
|
591
|
-
this.
|
591
|
+
this.isTextHighlightOn = false;
|
592
592
|
this._cursorIndex = -1;
|
593
593
|
this._markAsDirty();
|
594
594
|
return;
|
@@ -613,11 +613,11 @@ export class InputText extends Control {
|
|
613
613
|
this.onBeforeKeyAddObservable.notifyObservers(this);
|
614
614
|
key = this._currentKey;
|
615
615
|
if (this._addKey && !this._deadKey) {
|
616
|
-
if (this.
|
616
|
+
if (this.isTextHighlightOn) {
|
617
617
|
this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex, key);
|
618
618
|
this._textHasChanged();
|
619
619
|
this._cursorOffset = this._textWrapper.length - (this._startHighlightIndex + 1);
|
620
|
-
this.
|
620
|
+
this.isTextHighlightOn = false;
|
621
621
|
this._blinkIsEven = false;
|
622
622
|
this._markAsDirty();
|
623
623
|
}
|
@@ -651,12 +651,12 @@ export class InputText extends Control {
|
|
651
651
|
this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
|
652
652
|
}
|
653
653
|
else {
|
654
|
-
this.
|
654
|
+
this.isTextHighlightOn = false;
|
655
655
|
this._markAsDirty();
|
656
656
|
return;
|
657
657
|
}
|
658
658
|
}
|
659
|
-
this.
|
659
|
+
this.isTextHighlightOn = true;
|
660
660
|
this._markAsDirty();
|
661
661
|
}
|
662
662
|
/**
|
@@ -673,8 +673,7 @@ export class InputText extends Control {
|
|
673
673
|
moveLeft = this._startHighlightIndex > 0 && this._textWrapper.isWord(this._startHighlightIndex - 1) ? --this._startHighlightIndex : 0;
|
674
674
|
} while (moveLeft || moveRight);
|
675
675
|
this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
|
676
|
-
this.
|
677
|
-
this._isTextHighlightOn = true;
|
676
|
+
this.isTextHighlightOn = true;
|
678
677
|
this._clickedCoordinate = null;
|
679
678
|
this._blinkIsEven = true;
|
680
679
|
this._cursorIndex = -1;
|
@@ -683,7 +682,7 @@ export class InputText extends Control {
|
|
683
682
|
/** @internal */
|
684
683
|
_selectAllText() {
|
685
684
|
this._blinkIsEven = true;
|
686
|
-
this.
|
685
|
+
this.isTextHighlightOn = true;
|
687
686
|
this._startHighlightIndex = 0;
|
688
687
|
this._endHighlightIndex = this._textWrapper.length;
|
689
688
|
this._cursorOffset = this._textWrapper.length;
|
@@ -703,7 +702,7 @@ export class InputText extends Control {
|
|
703
702
|
* @internal
|
704
703
|
*/
|
705
704
|
_onCopyText(ev) {
|
706
|
-
this.
|
705
|
+
this.isTextHighlightOn = false;
|
707
706
|
//when write permission to clipbaord data is denied
|
708
707
|
try {
|
709
708
|
ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
|
@@ -720,7 +719,7 @@ export class InputText extends Control {
|
|
720
719
|
}
|
721
720
|
this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
|
722
721
|
this._textHasChanged();
|
723
|
-
this.
|
722
|
+
this.isTextHighlightOn = false;
|
724
723
|
this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
|
725
724
|
//when write permission to clipbaord data is denied
|
726
725
|
try {
|
@@ -847,7 +846,7 @@ export class InputText extends Control {
|
|
847
846
|
cursorLeft = clipTextLeft + availableWidth;
|
848
847
|
this._markAsDirty();
|
849
848
|
}
|
850
|
-
if (!this.
|
849
|
+
if (!this.isTextHighlightOn) {
|
851
850
|
context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
|
852
851
|
}
|
853
852
|
}
|
@@ -857,7 +856,7 @@ export class InputText extends Control {
|
|
857
856
|
this._markAsDirty();
|
858
857
|
}, 500);
|
859
858
|
//show the highlighted text
|
860
|
-
if (this.
|
859
|
+
if (this.isTextHighlightOn) {
|
861
860
|
clearTimeout(this._blinkTimeout);
|
862
861
|
const highlightCursorOffsetWidth = context.measureText(text.substring(this._startHighlightIndex)).width;
|
863
862
|
let highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
|
@@ -905,7 +904,7 @@ export class InputText extends Control {
|
|
905
904
|
return true;
|
906
905
|
}
|
907
906
|
this._clickedCoordinate = coordinates.x;
|
908
|
-
this.
|
907
|
+
this.isTextHighlightOn = false;
|
909
908
|
this._highlightedText = "";
|
910
909
|
this._cursorIndex = -1;
|
911
910
|
this._isPointerDown = true;
|
@@ -939,6 +938,20 @@ export class InputText extends Control {
|
|
939
938
|
_beforeRenderText(textWrapper) {
|
940
939
|
return textWrapper;
|
941
940
|
}
|
941
|
+
/** @internal */
|
942
|
+
set isTextHighlightOn(value) {
|
943
|
+
if (this._isTextHighlightOn === value) {
|
944
|
+
return;
|
945
|
+
}
|
946
|
+
if (value) {
|
947
|
+
this.onTextHighlightObservable.notifyObservers(this);
|
948
|
+
}
|
949
|
+
this._isTextHighlightOn = value;
|
950
|
+
}
|
951
|
+
/** @internal */
|
952
|
+
get isTextHighlightOn() {
|
953
|
+
return this._isTextHighlightOn;
|
954
|
+
}
|
942
955
|
dispose() {
|
943
956
|
super.dispose();
|
944
957
|
this.onBlurObservable.clear();
|