internal void SetElementUnderMouse(VisualElement newElementUnderMouse, EventBase triggerEvent) { if (newElementUnderMouse == topElementUnderMouse) { return; } VisualElement previousTopElementUnderMouse = topElementUnderMouse; topElementUnderMouse = newElementUnderMouse; IMouseEvent mouseEvent = triggerEvent == null ? null : triggerEvent as IMouseEvent; var mousePosition = mouseEvent == null ? MousePositionTracker.mousePosition : mouseEvent?.mousePosition ?? Vector2.zero; // mouse enter/leave must be dispatched *any* time the element under mouse changes using (new EventDispatcherGate(dispatcher)) { MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(previousTopElementUnderMouse, topElementUnderMouse, mouseEvent, mousePosition); } if (triggerEvent == null || triggerEvent.eventTypeId == MouseMoveEvent.TypeId() || triggerEvent.eventTypeId == MouseDownEvent.TypeId() || triggerEvent.eventTypeId == MouseUpEvent.TypeId() || triggerEvent.eventTypeId == MouseEnterWindowEvent.TypeId() || triggerEvent.eventTypeId == MouseLeaveWindowEvent.TypeId() || triggerEvent.eventTypeId == WheelEvent.TypeId()) { using (new EventDispatcherGate(dispatcher)) { MouseEventsHelper.SendMouseOverMouseOut(previousTopElementUnderMouse, topElementUnderMouse, mouseEvent, mousePosition); } } else if (triggerEvent.eventTypeId == DragUpdatedEvent.TypeId() || triggerEvent.eventTypeId == DragExitedEvent.TypeId()) { using (new EventDispatcherGate(dispatcher)) { MouseEventsHelper.SendEnterLeave <DragLeaveEvent, DragEnterEvent>(previousTopElementUnderMouse, topElementUnderMouse, mouseEvent, mousePosition); } } }
internal void SetElementUnderMouse(VisualElement newElementUnderMouse, EventBase triggerEvent) { if (newElementUnderMouse == topElementUnderMouse) { return; } VisualElement previousTopElementUnderMouse = topElementUnderMouse; topElementUnderMouse = newElementUnderMouse; if (triggerEvent == null) { using (new EventDispatcherGate(dispatcher)) { MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(previousTopElementUnderMouse, topElementUnderMouse, null, MousePositionTracker.mousePosition); MouseEventsHelper.SendMouseOverMouseOut(previousTopElementUnderMouse, topElementUnderMouse, null, MousePositionTracker.mousePosition); } } else if ( triggerEvent.eventTypeId == MouseMoveEvent.TypeId() || triggerEvent.eventTypeId == MouseDownEvent.TypeId() || triggerEvent.eventTypeId == MouseUpEvent.TypeId() || triggerEvent.eventTypeId == MouseEnterWindowEvent.TypeId() || triggerEvent.eventTypeId == MouseLeaveWindowEvent.TypeId() || triggerEvent.eventTypeId == WheelEvent.TypeId()) { IMouseEvent mouseEvent = triggerEvent as IMouseEvent; using (new EventDispatcherGate(dispatcher)) { MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(previousTopElementUnderMouse, topElementUnderMouse, mouseEvent, mouseEvent?.mousePosition ?? Vector2.zero); MouseEventsHelper.SendMouseOverMouseOut(previousTopElementUnderMouse, topElementUnderMouse, mouseEvent, mouseEvent?.mousePosition ?? Vector2.zero); } } else if (triggerEvent.eventTypeId == DragUpdatedEvent.TypeId() || triggerEvent.eventTypeId == DragExitedEvent.TypeId()) { IMouseEvent mouseEvent = triggerEvent as IMouseEvent; using (new EventDispatcherGate(dispatcher)) { MouseEventsHelper.SendEnterLeave <DragLeaveEvent, DragEnterEvent>(previousTopElementUnderMouse, topElementUnderMouse, mouseEvent, mouseEvent?.mousePosition ?? Vector2.zero); } } }
internal void CommitElementUnderPointers(EventDispatcher dispatcher) { for (int i = 0; i < this.m_TopElementUnderPointer.Length; i++) { IPointerEvent pointerEvent = this.m_TriggerPointerEvent[i]; VisualElement visualElement = this.m_TopElementUnderPointer[i]; VisualElement visualElement2 = this.m_PendingTopElementUnderPointer[i]; bool flag = visualElement2 == visualElement; if (flag) { bool flag2 = pointerEvent != null; if (flag2) { Vector3 position = pointerEvent.position; this.m_PickingPointerPositions[i] = new Vector2(position.x, position.y); } else { bool flag3 = this.m_TriggerMouseEvent[i] != null; if (flag3) { this.m_PickingPointerPositions[i] = this.m_TriggerMouseEvent[i].mousePosition; } } } else { this.m_TopElementUnderPointer[i] = visualElement2; bool flag4 = pointerEvent == null && this.m_TriggerMouseEvent[i] == null; if (flag4) { using (new EventDispatcherGate(dispatcher)) { Vector2 pointerPosition = PointerDeviceState.GetPointerPosition(i); PointerEventsHelper.SendOverOut(visualElement, visualElement2, null, pointerPosition, i); PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(visualElement, visualElement2, null, pointerPosition, i); this.m_PickingPointerPositions[i] = pointerPosition; bool flag5 = i == PointerId.mousePointerId; if (flag5) { MouseEventsHelper.SendMouseOverMouseOut(visualElement, visualElement2, null, pointerPosition); MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(visualElement, visualElement2, null, pointerPosition); } } } bool flag6 = pointerEvent != null; if (flag6) { Vector3 position2 = pointerEvent.position; this.m_PickingPointerPositions[i] = new Vector2(position2.x, position2.y); EventBase eventBase = pointerEvent as EventBase; bool flag7 = eventBase != null && (eventBase.eventTypeId == EventBase <PointerMoveEvent> .TypeId() || eventBase.eventTypeId == EventBase <PointerDownEvent> .TypeId() || eventBase.eventTypeId == EventBase <PointerUpEvent> .TypeId() || eventBase.eventTypeId == EventBase <PointerCancelEvent> .TypeId()); if (flag7) { using (new EventDispatcherGate(dispatcher)) { PointerEventsHelper.SendOverOut(visualElement, visualElement2, pointerEvent, position2, i); PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(visualElement, visualElement2, pointerEvent, position2, i); } } } this.m_TriggerPointerEvent[i] = null; IMouseEvent mouseEvent = this.m_TriggerMouseEvent[i]; bool flag8 = mouseEvent != null; if (flag8) { Vector2 mousePosition = mouseEvent.mousePosition; this.m_PickingPointerPositions[i] = mousePosition; EventBase eventBase2 = mouseEvent as EventBase; bool flag9 = eventBase2 != null; if (flag9) { bool flag10 = eventBase2.eventTypeId == EventBase <MouseMoveEvent> .TypeId() || eventBase2.eventTypeId == EventBase <MouseDownEvent> .TypeId() || eventBase2.eventTypeId == EventBase <MouseUpEvent> .TypeId() || eventBase2.eventTypeId == EventBase <WheelEvent> .TypeId(); if (flag10) { using (new EventDispatcherGate(dispatcher)) { MouseEventsHelper.SendMouseOverMouseOut(visualElement, visualElement2, mouseEvent, mousePosition); MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(visualElement, visualElement2, mouseEvent, mousePosition); } } else { bool flag11 = eventBase2.eventTypeId == EventBase <MouseEnterWindowEvent> .TypeId() || eventBase2.eventTypeId == EventBase <MouseLeaveWindowEvent> .TypeId(); if (flag11) { using (new EventDispatcherGate(dispatcher)) { PointerEventsHelper.SendOverOut(visualElement, visualElement2, null, mousePosition, i); PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(visualElement, visualElement2, null, mousePosition, i); bool flag12 = i == PointerId.mousePointerId; if (flag12) { MouseEventsHelper.SendMouseOverMouseOut(visualElement, visualElement2, mouseEvent, mousePosition); MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(visualElement, visualElement2, mouseEvent, mousePosition); } } } else { bool flag13 = eventBase2.eventTypeId == EventBase <DragUpdatedEvent> .TypeId() || eventBase2.eventTypeId == EventBase <DragExitedEvent> .TypeId(); if (flag13) { using (new EventDispatcherGate(dispatcher)) { PointerEventsHelper.SendOverOut(visualElement, visualElement2, null, mousePosition, i); PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(visualElement, visualElement2, null, mousePosition, i); MouseEventsHelper.SendMouseOverMouseOut(visualElement, visualElement2, mouseEvent, mousePosition); MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(visualElement, visualElement2, mouseEvent, mousePosition); MouseEventsHelper.SendEnterLeave <DragLeaveEvent, DragEnterEvent>(visualElement, visualElement2, mouseEvent, mousePosition); } } } } } this.m_TriggerMouseEvent[i] = null; } } } }