internal static ClickEvent GetPooled(PointerUpEvent pointerEvent, int clickCount) { var evt = PointerEventBase <ClickEvent> .GetPooled(pointerEvent); evt.clickCount = clickCount; return(evt); }
internal static ClickEvent GetPooled(PointerUpEvent pointerEvent, int clickCount) { ClickEvent pooled = PointerEventBase <ClickEvent> .GetPooled(pointerEvent); pooled.clickCount = clickCount; return(pooled); }
internal new static T GetPooled(EventBase e) { IPointerEvent pointerEvent = e as IPointerEvent; bool flag = pointerEvent != null; T pooled; if (flag) { pooled = PointerEventBase <T> .GetPooled(pointerEvent); } else { IMouseEvent mouseEvent = e as IMouseEvent; bool flag2 = mouseEvent != null; if (flag2) { pooled = PointerEventBase <T> .GetPooled(mouseEvent); } else { pooled = EventBase <T> .GetPooled(e); } } return(pooled); }
void ProcessPointerDown <T>(PointerEventBase <T> evt) where T : PointerEventBase <T>, new() { if (evt.button == (int)MouseButton.LeftMouse) { if (visualInput.ContainsPoint(visualInput.WorldToLocal(evt.originalMousePosition))) { ShowMenu(); evt.StopPropagation(); } } }
void ProcessPointerDown <T>(PointerEventBase <T> evt) where T : PointerEventBase <T>, new() { if (evt.button == (int)MouseButton.LeftMouse) { if (ContainsPointer(evt.pointerId)) { ShowMenu(); evt.StopPropagation(); } } }
internal static T GetPooled(IPointerEvent triggerEvent, Vector2 position, int pointerId) { bool flag = triggerEvent != null; T result; if (flag) { result = PointerEventBase <T> .GetPooled(triggerEvent); } else { T pooled = EventBase <T> .GetPooled(); pooled.position = position; pooled.localPosition = position; pooled.pointerId = pointerId; pooled.pointerType = PointerType.GetPointerType(pointerId); result = pooled; } return(result); }
internal static void SendOverOut(VisualElement previousTopElementUnderPointer, VisualElement currentTopElementUnderPointer, IPointerEvent triggerEvent, Vector2 position, int pointerId) { bool flag = previousTopElementUnderPointer != null && previousTopElementUnderPointer.panel != null; if (flag) { using (PointerOutEvent pooled = PointerEventBase <PointerOutEvent> .GetPooled(triggerEvent, position, pointerId)) { pooled.target = previousTopElementUnderPointer; previousTopElementUnderPointer.SendEvent(pooled); } } bool flag2 = currentTopElementUnderPointer != null; if (flag2) { using (PointerOverEvent pooled2 = PointerEventBase <PointerOverEvent> .GetPooled(triggerEvent, position, pointerId)) { pooled2.target = currentTopElementUnderPointer; currentTopElementUnderPointer.SendEvent(pooled2); } } }
internal static void SendEnterLeave <TLeaveEvent, TEnterEvent>(VisualElement previousTopElementUnderPointer, VisualElement currentTopElementUnderPointer, IPointerEvent triggerEvent, Vector2 position, int pointerId) where TLeaveEvent : PointerEventBase <TLeaveEvent>, new() where TEnterEvent : PointerEventBase <TEnterEvent>, new() { if (previousTopElementUnderPointer != null && previousTopElementUnderPointer.panel == null) { // If previousTopElementUnderPointer has been removed from panel, // do as if there is no element under the pointer. previousTopElementUnderPointer = null; } // We want to find the common ancestor CA of previousTopElementUnderPointer and currentTopElementUnderPointer, // send Leave (PointerLeave) events to elements between CA and previousTopElementUnderPointer // and send Enter (PointerEnter) events to elements between CA and currentTopElementUnderPointer. int prevDepth = 0; var p = previousTopElementUnderPointer; while (p != null) { prevDepth++; p = p.hierarchy.parent; } int currDepth = 0; var c = currentTopElementUnderPointer; while (c != null) { currDepth++; c = c.hierarchy.parent; } p = previousTopElementUnderPointer; c = currentTopElementUnderPointer; while (prevDepth > currDepth) { using (var leaveEvent = PointerEventBase <TLeaveEvent> .GetPooled(triggerEvent, position, pointerId)) { leaveEvent.target = p; p.SendEvent(leaveEvent); } prevDepth--; p = p.hierarchy.parent; } // We want to send enter events after all the leave events. // We will store the elements being entered in this list. List <VisualElement> enteringElements = VisualElementListPool.Get(currDepth); while (currDepth > prevDepth) { enteringElements.Add(c); currDepth--; c = c.hierarchy.parent; } // Now p and c are at the same depth. Go up the tree until p == c. while (p != c) { using (var leaveEvent = PointerEventBase <TLeaveEvent> .GetPooled(triggerEvent, position, pointerId)) { leaveEvent.target = p; p.SendEvent(leaveEvent); } enteringElements.Add(c); p = p.hierarchy.parent; c = c.hierarchy.parent; } for (var i = enteringElements.Count - 1; i >= 0; i--) { using (var enterEvent = PointerEventBase <TEnterEvent> .GetPooled(triggerEvent, position, pointerId)) { enterEvent.target = enteringElements[i]; enteringElements[i].SendEvent(enterEvent); } } VisualElementListPool.Release(enteringElements); }
internal static EventBase CreateEvent(Event systemEvent, EventType eventType) { EventBase pooled; switch (eventType) { case EventType.MouseDown: { bool flag = PointerDeviceState.HasAdditionalPressedButtons(PointerId.mousePointerId, systemEvent.button); if (flag) { pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent); return(pooled); } pooled = PointerEventBase <PointerDownEvent> .GetPooled(systemEvent); return(pooled); } case EventType.MouseUp: { bool flag2 = PointerDeviceState.HasAdditionalPressedButtons(PointerId.mousePointerId, systemEvent.button); if (flag2) { pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent); return(pooled); } pooled = PointerEventBase <PointerUpEvent> .GetPooled(systemEvent); return(pooled); } case EventType.MouseMove: pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent); return(pooled); case EventType.MouseDrag: pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent); return(pooled); case EventType.KeyDown: pooled = KeyboardEventBase <KeyDownEvent> .GetPooled(systemEvent); return(pooled); case EventType.KeyUp: pooled = KeyboardEventBase <KeyUpEvent> .GetPooled(systemEvent); return(pooled); case EventType.ScrollWheel: pooled = WheelEvent.GetPooled(systemEvent); return(pooled); case EventType.DragUpdated: pooled = DragUpdatedEvent.GetPooled(systemEvent); return(pooled); case EventType.DragPerform: pooled = MouseEventBase <DragPerformEvent> .GetPooled(systemEvent); return(pooled); case EventType.ValidateCommand: pooled = CommandEventBase <ValidateCommandEvent> .GetPooled(systemEvent); return(pooled); case EventType.ExecuteCommand: pooled = CommandEventBase <ExecuteCommandEvent> .GetPooled(systemEvent); return(pooled); case EventType.DragExited: pooled = DragExitedEvent.GetPooled(systemEvent); return(pooled); case EventType.ContextClick: pooled = MouseEventBase <ContextClickEvent> .GetPooled(systemEvent); return(pooled); case EventType.MouseEnterWindow: pooled = MouseEventBase <MouseEnterWindowEvent> .GetPooled(systemEvent); return(pooled); case EventType.MouseLeaveWindow: pooled = MouseLeaveWindowEvent.GetPooled(systemEvent); return(pooled); } pooled = IMGUIEvent.GetPooled(systemEvent); return(pooled); }
internal static void SendEnterLeave <TLeaveEvent, TEnterEvent>(VisualElement previousTopElementUnderPointer, VisualElement currentTopElementUnderPointer, IPointerEvent triggerEvent, Vector2 position, int pointerId) where TLeaveEvent : PointerEventBase <TLeaveEvent>, new() where TEnterEvent : PointerEventBase <TEnterEvent>, new() { bool flag = previousTopElementUnderPointer != null && previousTopElementUnderPointer.panel == null; if (flag) { previousTopElementUnderPointer = null; } int i = 0; VisualElement visualElement; for (visualElement = previousTopElementUnderPointer; visualElement != null; visualElement = visualElement.hierarchy.parent) { i++; } int j = 0; VisualElement visualElement2; for (visualElement2 = currentTopElementUnderPointer; visualElement2 != null; visualElement2 = visualElement2.hierarchy.parent) { j++; } visualElement = previousTopElementUnderPointer; visualElement2 = currentTopElementUnderPointer; while (i > j) { using (TLeaveEvent pooled = PointerEventBase <TLeaveEvent> .GetPooled(triggerEvent, position, pointerId)) { pooled.target = visualElement; visualElement.SendEvent(pooled); } i--; visualElement = visualElement.hierarchy.parent; } List <VisualElement> list = VisualElementListPool.Get(j); while (j > i) { list.Add(visualElement2); j--; visualElement2 = visualElement2.hierarchy.parent; } while (visualElement != visualElement2) { using (TLeaveEvent pooled2 = PointerEventBase <TLeaveEvent> .GetPooled(triggerEvent, position, pointerId)) { pooled2.target = visualElement; visualElement.SendEvent(pooled2); } list.Add(visualElement2); visualElement = visualElement.hierarchy.parent; visualElement2 = visualElement2.hierarchy.parent; } for (int k = list.Count - 1; k >= 0; k--) { using (TEnterEvent pooled3 = PointerEventBase <TEnterEvent> .GetPooled(triggerEvent, position, pointerId)) { pooled3.target = list[k]; list[k].SendEvent(pooled3); } } VisualElementListPool.Release(list); }
public static T GetPooled(Event systemEvent) { T pooled = EventBase <T> .GetPooled(); bool flag = !PointerEventBase <T> .IsMouse(systemEvent) && systemEvent.rawType != EventType.DragUpdated; if (flag) { Debug.Assert(false, string.Concat(new string[] { "Unexpected event type: ", systemEvent.rawType.ToString(), " (", systemEvent.type.ToString(), ")" })); } UnityEngine.PointerType pointerType = systemEvent.pointerType; UnityEngine.PointerType pointerType2 = pointerType; if (pointerType2 != UnityEngine.PointerType.Touch) { if (pointerType2 != UnityEngine.PointerType.Pen) { pooled.pointerType = PointerType.mouse; pooled.pointerId = PointerId.mousePointerId; } else { pooled.pointerType = PointerType.pen; pooled.pointerId = PointerId.penPointerIdBase; } } else { pooled.pointerType = PointerType.touch; pooled.pointerId = PointerId.touchPointerIdBase; } pooled.isPrimary = true; pooled.altitudeAngle = 0f; pooled.azimuthAngle = 0f; pooled.twist = 0f; pooled.radius = Vector2.zero; pooled.radiusVariance = Vector2.zero; pooled.imguiEvent = systemEvent; bool flag2 = systemEvent.rawType == EventType.MouseDown; if (flag2) { PointerDeviceState.PressButton(PointerId.mousePointerId, systemEvent.button); pooled.button = systemEvent.button; } else { bool flag3 = systemEvent.rawType == EventType.MouseUp; if (flag3) { PointerDeviceState.ReleaseButton(PointerId.mousePointerId, systemEvent.button); pooled.button = systemEvent.button; } else { bool flag4 = systemEvent.rawType == EventType.MouseMove; if (flag4) { pooled.button = -1; } } } pooled.pressedButtons = PointerDeviceState.GetPressedButtons(pooled.pointerId); pooled.position = systemEvent.mousePosition; pooled.localPosition = systemEvent.mousePosition; pooled.deltaPosition = systemEvent.delta; pooled.clickCount = systemEvent.clickCount; pooled.modifiers = systemEvent.modifiers; UnityEngine.PointerType pointerType3 = systemEvent.pointerType; UnityEngine.PointerType pointerType4 = pointerType3; if (pointerType4 - UnityEngine.PointerType.Touch > 1) { pooled.pressure = ((pooled.pressedButtons == 0) ? 0f : 0.5f); } else { pooled.pressure = systemEvent.pressure; } pooled.tangentialPressure = 0f; pooled.triggeredByOS = true; return(pooled); }