public static void ReleaseMouseCapture() { if (MouseCaptureController.mouseCapture != null) { using (MouseCaptureOutEvent pooled = MouseCaptureEventBase <MouseCaptureOutEvent> .GetPooled(MouseCaptureController.mouseCapture)) { UIElementsUtility.eventDispatcher.DispatchEvent(pooled, null); } } MouseCaptureController.mouseCapture = null; }
public static void TakeMouseCapture(this IEventHandler handler) { if (MouseCaptureController.mouseCapture != handler) { if (GUIUtility.hotControl != 0) { Debug.Log("Should not be capturing when there is a hotcontrol"); } else { MouseCaptureController.ReleaseMouseCapture(); MouseCaptureController.mouseCapture = handler; using (MouseCaptureEvent pooled = MouseCaptureEventBase <MouseCaptureEvent> .GetPooled(MouseCaptureController.mouseCapture)) { UIElementsUtility.eventDispatcher.DispatchEvent(pooled, null); } } } }