Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit b4f2b9c

Browse files
authored
Merge pull request #345 from UnityTech/dev
Dev
2 parents f2b8891 + c8a9f81 commit b4f2b9c

File tree

4 files changed

+31
-38
lines changed

4 files changed

+31
-38
lines changed

Runtime/rendering/editable.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,7 @@ void _paintContents(PaintingContext context, Offset offset) {
15271527
else if (!this._selection.isCollapsed && this._selectionColor != null) {
15281528
showSelection = true;
15291529
}
1530+
this._updateSelectionExtentsVisibility(effectiveOffset);
15301531
}
15311532

15321533
if (showSelection) {

Runtime/rendering/list_wheel_viewport.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -650,41 +650,6 @@ Offset offsetToCenter
650650
);
651651
}
652652

653-
Matrix4x4 _magnifyTransform() {
654-
Matrix4x4 magnify = Matrix4x4.identity;
655-
magnify.translate(this.size.width * (-this._offAxisFraction + 0.5f), this.size.height / 2f);
656-
magnify.scale(this._magnification, this._magnification, this._magnification);
657-
magnify.translate(-this.size.width * (-this._offAxisFraction + 0.5f), -this.size.height / 2f);
658-
return magnify;
659-
}
660-
661-
Matrix3 _centerOriginTransform(Matrix3 originalMatrix) {
662-
Matrix3 result = Matrix3.I();
663-
Offset centerOriginTranslation = Alignment.center.alongSize(this.size);
664-
result.setTranslate(centerOriginTranslation.dx * (-this._offAxisFraction * 2 + 1),
665-
centerOriginTranslation.dy);
666-
result.multiply(originalMatrix);
667-
result.setTranslate(-centerOriginTranslation.dx * (-this._offAxisFraction * 2 + 1),
668-
-centerOriginTranslation.dy);
669-
return result;
670-
}
671-
672-
Matrix4x4 _centerOriginTransform(Matrix4x4 originalMatrix) {
673-
Matrix4x4 result = Matrix4x4.identity;
674-
Offset centerOriginTranslation = Alignment.center.alongSize(this.size);
675-
result.translate(centerOriginTranslation.dx * (-this._offAxisFraction * 2 + 1),
676-
centerOriginTranslation.dy);
677-
result.multiply(originalMatrix);
678-
result.translate(-centerOriginTranslation.dx * (-this._offAxisFraction * 2 + 1),
679-
-centerOriginTranslation.dy);
680-
return result;
681-
}
682-
683-
public void applyPaintTransform(RenderBox child, Matrix4x4 transform) {
684-
ListWheelParentData parentData = (ListWheelParentData) child?.parentData;
685-
transform.translate(0.0f, this._getUntransformedPaintingCoordinateY(parentData.offset.dy));
686-
}
687-
688653
public override Rect describeApproximatePaintClip(RenderObject child) {
689654
if (child != null && this._shouldClipAtCurrentOffset()) {
690655
return Offset.zero & this.size;

Runtime/service/text_formatter.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,32 @@ public override TextEditingValue formatEditUpdate(TextEditingValue oldValue, Tex
8181
}
8282
}
8383

84+
public class WhitelistingTextInputFormatter : TextInputFormatter {
85+
public WhitelistingTextInputFormatter(Regex whitelistedPattern) {
86+
D.assert(whitelistedPattern != null);
87+
this.whitelistedPattern = whitelistedPattern;
88+
}
89+
90+
readonly Regex whitelistedPattern;
91+
92+
public override TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
93+
return Util._selectionAwareTextManipulation(
94+
value: newValue,
95+
substringManipulation: substring => {
96+
string groups = "";
97+
foreach (Match match in this.whitelistedPattern.Matches(input: substring)) {
98+
groups += match.Groups[0].Value;
99+
}
100+
101+
return groups;
102+
}
103+
);
104+
}
105+
106+
public static readonly WhitelistingTextInputFormatter digitsOnly
107+
= new WhitelistingTextInputFormatter(new Regex(@"\d+"));
108+
}
109+
84110
static class Util {
85111
internal static TextEditingValue _selectionAwareTextManipulation(TextEditingValue value,
86112
Func<string, string> substringManipulation) {

Runtime/widgets/text_selection.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Unity.UIWidgets.scheduler;
99
using Unity.UIWidgets.service;
1010
using Unity.UIWidgets.ui;
11+
using Rect = Unity.UIWidgets.ui.Rect;
1112

1213
namespace Unity.UIWidgets.widgets {
1314
static class TextSelectionUtils {
@@ -96,10 +97,10 @@ public void handlePaste(TextSelectionDelegate selectionDelegate) {
9697
offset: value.selection.start + data.text.Length
9798
)
9899
);
100+
101+
selectionDelegate.bringIntoView(selectionDelegate.textEditingValue.selection.extendPos);
102+
selectionDelegate.hideToolbar();
99103
}
100-
101-
selectionDelegate.bringIntoView(selectionDelegate.textEditingValue.selection.extendPos);
102-
selectionDelegate.hideToolbar();
103104
});
104105
}
105106

0 commit comments

Comments
 (0)