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

Commit 567618d

Browse files
authored
Merge pull request #160 from UnityTech/textselection
fix sample errors
2 parents 856b8a2 + b1f1563 commit 567618d

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

Samples/UIWidgetSample/txt/TextFieldSample.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
namespace UIWidgetsSample {
99
public class TextFieldSample : UIWidgetsSamplePanel {
10-
protected override void Awake() {
11-
base.Awake();
12-
FontManager.instance.addFont(Resources.Load<Font>(path: "MaterialIcons-Regular"), "Material Icons");
13-
}
14-
1510
protected override Widget createWidget() {
1611
return new MaterialApp(
1712
title: "Text Fields",
1813
home: new MyCustomForm()
1914
);
2015
}
16+
17+
protected override void OnEnable() {
18+
base.OnEnable();
19+
FontManager.instance.addFont(Resources.Load<Font>(path: "MaterialIcons-Regular"), "Material Icons");
20+
}
2121
}
2222

2323
class MyCustomForm : StatefulWidget {

Tests/Editor/RenderEditable.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
using TextStyle = Unity.UIWidgets.painting.TextStyle;
1616

1717
namespace UIWidgets.Tests {
18-
public class RenderEditable : EditorWindow {
18+
public class RenderEditable : EditorWindow, TextSelectionDelegate {
1919
readonly Func<RenderBox>[] _options;
2020

2121
readonly string[] _optionStrings;
@@ -150,7 +150,8 @@ RenderBox textEditable() {
150150
new _FixedViewportOffset(0.0f), new ValueNotifier<bool>(true),
151151
onSelectionChanged: this.selectionChanged, cursorColor: Color.fromARGB(255, 0, 0, 0),
152152
maxLines: 100,
153-
selectionColor: Color.fromARGB(255, 255, 0, 0))
153+
selectionColor: Color.fromARGB(255, 255, 0, 0),
154+
textSelectionDelegate: this)
154155
));
155156

156157
span = new TextSpan("", children:
@@ -164,7 +165,8 @@ RenderBox textEditable() {
164165
new _FixedViewportOffset(0.0f), new ValueNotifier<bool>(true),
165166
onSelectionChanged: this.selectionChanged, cursorColor: Color.fromARGB(255, 0, 0, 0),
166167
maxLines: 100,
167-
selectionColor: Color.fromARGB(255, 255, 0, 0))
168+
selectionColor: Color.fromARGB(255, 255, 0, 0),
169+
textSelectionDelegate: this)
168170
));
169171

170172
span = new TextSpan("", children:
@@ -175,7 +177,8 @@ RenderBox textEditable() {
175177
new Unity.UIWidgets.rendering.RenderEditable(span, TextDirection.ltr,
176178
new _FixedViewportOffset(0.0f), new ValueNotifier<bool>(true),
177179
onSelectionChanged: this.selectionChanged, cursorColor: Color.fromARGB(255, 0, 0, 0),
178-
selectionColor: Color.fromARGB(255, 255, 0, 0))
180+
selectionColor: Color.fromARGB(255, 255, 0, 0),
181+
textSelectionDelegate: this)
179182
, width: 300));
180183
return flexbox;
181184
}
@@ -186,5 +189,13 @@ void selectionChanged(TextSelection selection, Unity.UIWidgets.rendering.RenderE
186189
Debug.Log($"selection {selection}");
187190
renderObject.selection = selection;
188191
}
192+
193+
public TextEditingValue textEditingValue { get; set; }
194+
195+
public void hideToolbar() {
196+
}
197+
198+
public void bringIntoView(TextPosition textPosition) {
199+
}
189200
}
190201
}

0 commit comments

Comments
 (0)