浏览代码

pointer hover bug fix

/main
xingwei.zhu 6 年前
当前提交
7419b36c
共有 5 个文件被更改,包括 13 次插入11 次删除
  1. 4
      Runtime/gestures/binding.cs
  2. 2
      Runtime/gestures/events.cs
  3. 3
      Runtime/gestures/mouse_tracking.cs
  4. 2
      Runtime/rendering/binding.cs
  5. 13
      Tests/Editor/MouseHover.cs

4
Runtime/gestures/binding.cs


return;
}
if (evt is PointerHoverEvent) {
this._handlePointerHoverEvent(evt);
}
HitTestResult hitTestResult = null;
if (evt is PointerDownEvent) {
D.assert(!this._hitTests.ContainsKey(evt.pointer));

2
Runtime/gestures/events.cs


down: false) {
}
public static PointerExitEvent fromHoverEvent(PointerHoverEvent hover) {
public static PointerExitEvent fromHoverEvent(PointerEvent hover) {
return new PointerExitEvent(
timeStamp: hover.timeStamp,
pointer: hover.pointer,

3
Runtime/gestures/mouse_tracking.cs


void exitAnnotation(_TrackedAnnotation trackedAnnotation, int deviceId) {
if (trackedAnnotation.annotation?.onExit != null &&
trackedAnnotation.activeDevices.Contains(deviceId)) {
trackedAnnotation.annotation.onExit(PointerExitEvent.fromHoverEvent((PointerHoverEvent)this._lastMouseEvent[deviceId]));
trackedAnnotation.annotation.onExit(PointerExitEvent.fromHoverEvent(this._lastMouseEvent[deviceId]));
trackedAnnotation.activeDevices.Remove(deviceId);
}
}

2
Runtime/rendering/binding.cs


MouseTracker _createMouseTracker() {
return new MouseTracker(this.pointerRouter, (Offset offset) => {
return this.renderView.layer.find<MouseTrackerAnnotation>(
offset * Window.instance.devicePixelRatio
offset
);
});
}

13
Tests/Editor/MouseHover.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
namespace UIWidgets.Tests {
public class MouseHoverWidget : StatefulWidget {

Widget result = new Container(width: 200, height: 60, color: Color.fromARGB(255, 255, 0, 255));
if (canHover) {
result = new HoverTrackWidget(null,
result);
result, "inner");
}
if (nest) {

result);
result, "outer");
}
return result;

public class HoverTrackWidget : StatefulWidget {
public readonly Widget child;
public readonly string name;
public HoverTrackWidget(Key key, Widget child) : base(key) {
public HoverTrackWidget(Key key, Widget child, string name) : base(key) {
this.name = name;
}
public override State createState() {

),
onPointerEnter: (evt) => {
if (this.mounted) {
Debug.Log(this.widget.name + " pointer enter");
Debug.Log(this.widget.name + " pointer exit");
this.setState(() => { this.hover = false; });
}
}

正在加载...
取消
保存