public void ProcessPointerCapture(int pointerId) { if (m_PointerCapture[pointerId] == m_PendingPointerCapture[pointerId]) { return; } if (m_PointerCapture[pointerId] != null) { using (var e = PointerCaptureOutEvent.GetPooled(m_PointerCapture[pointerId], m_PendingPointerCapture[pointerId], pointerId)) { m_PointerCapture[pointerId].SendEvent(e); } if (pointerId == PointerId.mousePointerId) { using (var e = MouseCaptureOutEvent.GetPooled(m_PointerCapture[pointerId], m_PendingPointerCapture[pointerId], pointerId)) { m_PointerCapture[pointerId].SendEvent(e); } } } if (m_PendingPointerCapture[pointerId] != null) { using (var e = PointerCaptureEvent.GetPooled(m_PendingPointerCapture[pointerId], m_PointerCapture[pointerId], pointerId)) { m_PendingPointerCapture[pointerId].SendEvent(e); } if (pointerId == PointerId.mousePointerId) { using (var e = MouseCaptureEvent.GetPooled(m_PendingPointerCapture[pointerId], m_PointerCapture[pointerId], pointerId)) { m_PendingPointerCapture[pointerId].SendEvent(e); } } } m_PointerCapture[pointerId] = m_PendingPointerCapture[pointerId]; }
public static void TakeMouseCapture(this IEventHandler handler) { if (mouseCapture == handler) { return; } if (GUIUtility.hotControl != 0) { Debug.Log("Should not be capturing when there is a hotcontrol"); return; } // TODO: assign a reserved control id to hotControl so that repaint events in OnGUI() have their hotcontrol check behave normally ReleaseMouseCapture(); mouseCapture = handler; using (MouseCaptureEvent e = MouseCaptureEvent.GetPooled(mouseCapture)) { UIElementsUtility.eventDispatcher.DispatchEvent(e, null); } }
public static void CaptureMouse(this IEventHandler handler) { if (mouseCapture == handler) { return; } if (handler == null) { ReleaseMouse(); return; } if (GUIUtility.hotControl != 0) { Debug.Log("Should not be capturing when there is a hotcontrol"); return; } // TODO: assign a reserved control id to hotControl so that repaint events in OnGUI() have their hotcontrol check behave normally IEventHandler currentMouseCapture = mouseCapture; mouseCapture = handler; if (currentMouseCapture != null) { using (MouseCaptureOutEvent releaseEvent = MouseCaptureOutEvent.GetPooled(currentMouseCapture, mouseCapture)) { currentMouseCapture.SendEvent(releaseEvent); } } using (MouseCaptureEvent captureEvent = MouseCaptureEvent.GetPooled(mouseCapture, currentMouseCapture)) { mouseCapture.SendEvent(captureEvent); } }