浏览代码

add missing recognizer into textspan

/main
fzhangtj 6 年前
当前提交
6e186c96
共有 2 个文件被更改,包括 42 次插入4 次删除
  1. 33
      Runtime/painting/text_span.cs
  2. 13
      Runtime/rendering/paragraph.cs

33
Runtime/painting/text_span.cs


public readonly List<TextSpan> children;
public readonly GestureRecognizer recognizer;
public TextSpan(string text = "", TextStyle style = null, List<TextSpan> children = null) {
public TextSpan(string text = "", TextStyle style = null, List<TextSpan> children = null,
GestureRecognizer recognizer = null) {
this.recognizer = recognizer;
}
public void build(ParagraphBuilder builder, float textScaleFactor = 1.0f) {

return true;
}
TextSpan getSpanForPosition(TextPosition position) {
public TextSpan getSpanForPosition(TextPosition position) {
D.assert(this.debugAssertIsValid());
var offset = 0;
var targetOffset = position.offset;
var affinity = position.affinity;

});
return result;
}
public string toPlainText() {
var sb = new StringBuilder();
this.visitTextSpan((span) => {

return result;
}
bool debugAssertIsValid() {
D.assert(() => {
if (!this.visitTextSpan(span => {
if (span.children != null) {
foreach (TextSpan child in span.children) {
if (child == null)
return false;
}
}
return true;
})) {
throw new UIWidgetsError(
"A TextSpan object with a non-null child list should not have any nulls in its child list.\n" +
"The full text in question was:\n" +
this.toStringDeep(prefixLineOne:" "));
}
return true;
});
return true;
}
public RenderComparison compareTo(TextSpan other) {
if (this.Equals(other)) {
return RenderComparison.identical;

unchecked {
var hashCode = (this.style != null ? this.style.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.text != null ? this.text.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.recognizer != null ? this.recognizer.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.childHash());
return hashCode;
}

}
return Equals(this.style, other.style) && string.Equals(this.text, other.text) &&
childEquals(this.children, other.children);
childEquals(this.children, other.children) && this.recognizer == other.recognizer;
}
public static bool operator ==(TextSpan left, TextSpan right) {

13
Runtime/rendering/paragraph.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;

protected override bool hitTestSelf(Offset position) {
return true;
}
public override void handleEvent(PointerEvent evt, HitTestEntry entry) {
D.assert(this.debugHandleEvent(evt, entry));
if (!(evt is PointerDownEvent)) {
return;
}
this._layoutTextWithConstraints(this.constraints);
Offset offset = ((BoxHitTestEntry)entry).localPosition;
TextPosition position = this._textPainter.getPositionForOffset(offset);
TextSpan span = this._textPainter.text.getSpanForPosition(position);
span?.recognizer?.addPointer((PointerDownEvent)evt);
}
protected override void performLayout() {

正在加载...
取消
保存