浏览代码

fix text_selection

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
6ed77e3d
共有 6 个文件被更改,包括 105 次插入98 次删除
  1. 40
      com.unity.uiwidgets/Runtime/cupertino/text_selection.cs
  2. 7
      com.unity.uiwidgets/Runtime/widgets/editable_text.cs
  3. 2
      com.unity.uiwidgets/Runtime/widgets/focus_manager.cs
  4. 137
      com.unity.uiwidgets/Runtime/widgets/focus_scope.cs
  5. 4
      com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs
  6. 13
      com.unity.uiwidgets/Runtime/widgets/text_selection.cs

40
com.unity.uiwidgets/Runtime/cupertino/text_selection.cs


}
class _CupertinoTextSelectionControls : TextSelectionControls {
public override Size getHandleSize(float textLineHeight) {
return new Size(
CupertinoTextSelectionUtils._kSelectionHandleRadius * 2,
textLineHeight + CupertinoTextSelectionUtils._kSelectionHandleRadius * 2 -
CupertinoTextSelectionUtils._kSelectionHandleOverlap
);
}
public override Widget buildToolbar(BuildContext context, Rect globalEditableRegion, Offset position,
public override Offset getHandleAnchor(TextSelectionHandleType type, float textLineHeight) {
Size handleSize = getHandleSize(textLineHeight);
switch (type) {
case TextSelectionHandleType.left:
return new Offset(
handleSize.width / 2,
handleSize.height
);
case TextSelectionHandleType.right:
return new Offset(
handleSize.width / 2,
handleSize.height - 2 * CupertinoTextSelectionUtils._kSelectionHandleRadius + CupertinoTextSelectionUtils._kSelectionHandleOverlap
);
default:
return new Offset(
handleSize.width / 2,
textLineHeight + (handleSize.height - textLineHeight) / 2
);
}
}
public override Widget buildToolbar(
BuildContext context,
Rect globalEditableRegion,
float textLineHeight,
Offset position,
List<TextSelectionPoint> endpoints,
TextSelectionDelegate del) {
D.assert(WidgetsD.debugCheckHasMediaQuery(context));
return new ConstrainedBox(

7
com.unity.uiwidgets/Runtime/widgets/editable_text.cs


_openInputConnection();
}
else {
List<FocusScopeNode> ancestorScopes = FocusScope.ancestorsOf(context);
for (int i = ancestorScopes.Count - 1; i >= 1; i -= 1) {
ancestorScopes[i].setFirstFocus(ancestorScopes[i - 1]);
}
FocusScope.of(context).requestFocus(widget.focusNode);
widget.focusNode.requestFocus();
}
}

2
com.unity.uiwidgets/Runtime/widgets/focus_manager.cs


get { return FocusManager.instance.highlightMode; }
}
FocusScopeNode nearestScope {
public FocusScopeNode nearestScope {
get { return enclosingScope; }
}

137
com.unity.uiwidgets/Runtime/widgets/focus_scope.cs


}
}
public class FocusScope : StatefulWidget {
public FocusScope(FocusScopeNode node, Widget child, Key key = null, bool autofocus = false) : base(key) {
this.node = node;
this.child = child;
this.autofocus = autofocus;
public class FocusScope : Focus {
public FocusScope(
Key key = null,
FocusScopeNode node = null,
Widget child = null,
bool autofocus = false,
ValueChanged<bool> onFocusChange = null,
bool? canRequestFocus = null,
bool? skipTraversal = null,
FocusOnKeyCallback onKey = null,
string debugLabel = null
) : base(
key: key,
child: child,
focusNode: node,
autofocus: autofocus,
onFocusChange: onFocusChange,
canRequestFocus: canRequestFocus,
skipTraversal: skipTraversal,
onKey: onKey,
debugLabel: debugLabel) {
D.assert(child != null);
D.assert(autofocus != null);
public readonly FocusScopeNode node;
public readonly bool autofocus;
public readonly Widget child;
var scope = (_FocusScopeMarker) context.inheritFromWidgetOfExactType(typeof(_FocusScopeMarker));
if (scope != null && scope.node != null) {
return scope.node;
}
return context.owner.focusManager.rootScope;
}
public static List<FocusScopeNode> ancestorsOf(BuildContext context) {
D.assert(context != null);
List<FocusScopeNode> ancestors = new List<FocusScopeNode> { };
while (true) {
context = context.ancestorInheritedElementForWidgetOfExactType(typeof(_FocusScopeMarker));
if (context == null) {
return ancestors;
}
_FocusScopeMarker scope = (_FocusScopeMarker) context.widget;
ancestors.Add(scope.node);
context.visitAncestorElements((Element parent) => {
context = parent;
return false;
});
}
_FocusMarker marker = context.dependOnInheritedWidgetOfExactType<_FocusMarker>();
return marker?.notifier?.nearestScope ?? context.owner.focusManager.rootScope;
class _FocusScopeState : _FocusState {
public FocusScopeNode _createNode() {
return new FocusScopeNode(
debugLabel: widget.debugLabel,
canRequestFocus: widget.canRequestFocus ?? true,
skipTraversal: widget.skipTraversal ?? false
);
}
public override Widget build(BuildContext context) {
_focusAttachment.reparent();
return new _FocusMarker(
node: focusNode,
child: widget.child);
}
}
class _FocusMarker : InheritedNotifier<FocusNode> {
public _FocusMarker(
Key key = null,
FocusNode node = null,
Widget child = null
) : base(key: key, notifier: node, child: child) {
D.assert(node != null);
D.assert(child != null);
}
}
public class Focus : StatefulWidget {
public Focus(

}
return node;
}
//public static bool isAt(BuildContext context) => Focus.of(context, nullOk: true)?.hasFocus ?? false;
public static bool isAt(BuildContext context) => Focus.of(context, nullOk: true)?.hasFocus ?? false;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new StringProperty("debugLabel", debugLabel, defaultValue: null));

}
}
/*class _FocusScopeState : State<FocusScope> {
bool _didAutofocus = false;
public override void didChangeDependencies() {
base.didChangeDependencies();
if (!_didAutofocus && widget.autofocus) {
FocusScope.of(context).setFirstFocus(widget.node);
_didAutofocus = true;
}
}
public override void dispose() {
widget.node.detach();
base.dispose();
}
public override Widget build(BuildContext context) {
FocusScope.of(context).reparentScopeIfNeeded(widget.node);
return new _FocusScopeMarker(node: widget.node, child: widget.child);
}
}*/
class _FocusScopeState : _FocusState {
public FocusScopeNode _createNode() {
return new FocusScopeNode(
debugLabel: widget.debugLabel,
canRequestFocus: widget.canRequestFocus ?? true,
skipTraversal: widget.skipTraversal ?? false
);
}
public override Widget build(BuildContext context) {
_focusAttachment.reparent();
return new _FocusMarker(
node: focusNode,
child: widget.child);
}
}
class _FocusMarker : InheritedNotifier<FocusNode> {
public _FocusMarker(
Key key = null,
FocusNode node = null,
Widget child = null
) : base(key: key, notifier: node, child: child) {
D.assert(node != null);
D.assert(child != null);
}
}
}

4
com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs


namespace Unity.UIWidgets.widgets {
public class FocusTraversalGroup : StatefulWidget {
/*public class FocusTraversalGroup : StatefulWidget {
public FocusTraversalGroup(
Key key = null,
FocusTraversalPolicy policy = null,

}
return sortedList;
}
}
}*/
}

13
com.unity.uiwidgets/Runtime/widgets/text_selection.cs


}
bool canCopy(TextSelectionDelegate _delegate) {
public bool canCopy(TextSelectionDelegate _delegate) {
bool canPaste(TextSelectionDelegate _delegate) {
public bool canPaste(TextSelectionDelegate _delegate) {
bool canSelectAll(TextSelectionDelegate _delegate) {
public bool canSelectAll(TextSelectionDelegate _delegate) {
return _delegate.selectAllEnabled
&& _delegate.textEditingValue.text.isNotEmpty()
&& _delegate.textEditingValue.selection.isCollapsed;

link: layerLink,
showWhenUnlinked: false,
offset: -editingRegion.topLeft,
child: selectionControls.buildToolbar(context, editingRegion, midpoint, selectionDelegate)
child: selectionControls.buildToolbar(context,
editingRegion,
renderObject.preferredLineHeight,
midpoint,
endpoints,
selectionDelegate)
)
);
}

正在加载...
取消
保存