void OnMouseCaptureOutEvent(MouseCaptureOutEvent e) { if (m_Active) { Reset(); } }
void OnMouseCaptureOutEvent(MouseCaptureOutEvent e) { if (m_Active) { m_Rectangle.RemoveFromHierarchy(); m_Active = false; } }
void OnCaptureOut(MouseCaptureOutEvent e) { active = false; if (edgeCandidate != null) { Abort(); } }
void OnCaptureOut(MouseCaptureOutEvent e) { m_Active = false; if (m_EdgeDragHelper.edgeCandidateModel != null) { Abort(); } }
public static void ReleaseMouseCapture() { if (MouseCaptureController.mouseCapture != null) { using (MouseCaptureOutEvent pooled = MouseCaptureEventBase <MouseCaptureOutEvent> .GetPooled(MouseCaptureController.mouseCapture)) { UIElementsUtility.eventDispatcher.DispatchEvent(pooled, null); } } MouseCaptureController.mouseCapture = null; }
void OpacityChangeEnd(MouseCaptureOutEvent evt) { if (IsOpacityTarget(evt.target, m_BoneOpacitySlider)) { onBoneOpacitySliderChangeEnd(); } else if (IsOpacityTarget(evt.target, m_MeshOpacitySlider)) { onMeshOpacitySliderChangeEnd(); } }
public static void ReleaseMouseCapture() { if (mouseCapture != null) { using (MouseCaptureOutEvent e = MouseCaptureOutEvent.GetPooled(mouseCapture)) { UIElementsUtility.eventDispatcher.DispatchEvent(e, null); } } mouseCapture = null; }
private void OnCaptureOut(MouseCaptureOutEvent evt) { if (!m_Active) { return; } m_Graph.RemoveEdgeElement(m_ConnectingEdge); m_Active = false; m_ConnectingEdge = null; target.ReleaseMouse(); }
public static void ReleaseMouse() { if (mouseCapture != null) { IEventHandler currentMouseCapture = mouseCapture; mouseCapture = null; using (MouseCaptureOutEvent e = MouseCaptureOutEvent.GetPooled(currentMouseCapture, null)) { currentMouseCapture.SendEvent(e); } } }
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]; }
private void OnMouseCaptureOutEvent(MouseCaptureOutEvent e) { if (m_Active) { if (m_PrevDropTarget != null && m_GraphView != null) { if (m_PrevDropTarget.CanAcceptDrop(m_GraphView.selection)) { m_PrevDropTarget.DragExited(); } } // Stop processing the event sequence if the target has lost focus, then. selectedElement = null; m_PrevDropTarget = null; m_Active = false; } }
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); } }
/// <summary> /// Callback for the MouseCaptureOut event. /// </summary> /// <param name="e">The event.</param> protected void OnMouseCaptureOutEvent(MouseCaptureOutEvent e) { if (m_Active) { if (m_CurrentDropTarget != null && m_GraphView != null) { using (DragExitedEvent eExit = DragExitedEvent.GetPooled()) { eExit.target = m_CurrentDropTarget; m_GraphView.SendEvent(eExit); } } // Stop processing the event sequence if the target has lost focus, then. m_SelectedElement = null; m_CurrentDropTarget = null; m_Active = false; if (m_GraphView?.GetSelection().Any() ?? false) { m_Snapper.EndSnap(); } } }
private void OnMouseCaptureOut(MouseCaptureOutEvent e) => m_ReadyToDrag = false;
protected void OnMouseCaptureOut(MouseCaptureOutEvent evt) { m_Focus = false; }
public void DispatchEvent(EventBase evt, IPanel panel) { if (evt.GetEventTypeId() == IMGUIEvent.TypeId()) { Event e = evt.imguiEvent; if (e.type == EventType.Repaint) { return; } } if (panel != null && panel.panelDebug != null && panel.panelDebug.enabled && panel.panelDebug.interceptEvents != null) { if (panel.panelDebug.interceptEvents(evt.imguiEvent)) { evt.StopPropagation(); return; } } IMouseEvent mouseEvent = evt as IMouseEvent; IMouseEventInternal mouseEventInternal = evt as IMouseEventInternal; if (mouseEvent != null && mouseEventInternal != null && mouseEventInternal.hasUnderlyingPhysicalEvent) { m_LastMousePosition = mouseEvent.mousePosition; } bool eventHandled = false; // Release mouse capture if capture element is not in a panel. VisualElement captureVE = MouseCaptureController.mouseCapture as VisualElement; if (evt.GetEventTypeId() != MouseCaptureOutEvent.TypeId() && captureVE != null && captureVE.panel == null) { Event e = evt.imguiEvent; Debug.Log(String.Format("Capture has no panel, forcing removal (capture={0} eventType={1})", MouseCaptureController.mouseCapture, e != null ? e.type.ToString() : "null")); MouseCaptureController.ReleaseMouseCapture(); } // Send all IMGUI events (for backward compatibility) and MouseEvents with null target (because thats what we want to do in the new system) // to the capture, if there is one. Note that events coming from IMGUI have their target set to null. bool sendEventToMouseCapture = false; bool mouseEventWasCaptured = false; if (MouseCaptureController.mouseCapture != null) { if (evt.imguiEvent != null && evt.target == null) { // Non exclusive processing by capturing element. sendEventToMouseCapture = true; mouseEventWasCaptured = false; } if (mouseEvent != null && (evt.target == null || evt.target == MouseCaptureController.mouseCapture)) { // Exclusive processing by capturing element. sendEventToMouseCapture = true; mouseEventWasCaptured = true; } if (panel != null) { if (captureVE != null && captureVE.panel.contextType != panel.contextType) { // Capturing element is not in the right context. Ignore it. sendEventToMouseCapture = false; mouseEventWasCaptured = false; } } } evt.skipElement = null; if (sendEventToMouseCapture) { IEventHandler originalCaptureElement = MouseCaptureController.mouseCapture; eventHandled = true; evt.dispatch = true; evt.target = MouseCaptureController.mouseCapture; evt.currentTarget = MouseCaptureController.mouseCapture; evt.propagationPhase = PropagationPhase.AtTarget; MouseCaptureController.mouseCapture.HandleEvent(evt); // Do further processing with a target computed the usual way. // However, if mouseEventWasCaptured, the only thing remaining to do is ExecuteDefaultAction, // which whould be done with mouseCapture as the target. if (!mouseEventWasCaptured) { evt.target = null; } evt.currentTarget = null; evt.propagationPhase = PropagationPhase.None; evt.dispatch = false; // Do not call HandleEvent again for this element. evt.skipElement = originalCaptureElement; } if (!mouseEventWasCaptured && !evt.isPropagationStopped) { if (evt is IKeyboardEvent && panel != null) { eventHandled = true; if (panel.focusController.focusedElement != null) { IMGUIContainer imguiContainer = panel.focusController.focusedElement as IMGUIContainer; if (imguiContainer != null) { // THINK ABOUT THIS PF: shoudln't we allow for the capture dispatch phase? if (imguiContainer != evt.skipElement && imguiContainer.HandleIMGUIEvent(evt.imguiEvent)) { evt.StopPropagation(); evt.PreventDefault(); } } else { evt.target = panel.focusController.focusedElement; PropagateEvent(evt); } } else { evt.target = panel.visualTree; PropagateEvent(evt); if (!evt.isPropagationStopped) { PropagateToIMGUIContainer(panel.visualTree, evt); } } } else if (mouseEvent != null) { // FIXME: we should not change hover state when capture is true. // However, when doing drag and drop, drop target should be highlighted. // TODO when EditorWindow is docked MouseLeaveWindow is not always sent // this is a problem in itself but it could leave some elements as "hover" if (evt.GetEventTypeId() == MouseLeaveWindowEvent.TypeId()) { VisualElement currentTopElementUnderMouse = m_TopElementUnderMouse; m_TopElementUnderMouse = null; DispatchMouseEnterMouseLeave(currentTopElementUnderMouse, m_TopElementUnderMouse, mouseEvent); DispatchMouseOverMouseOut(currentTopElementUnderMouse, m_TopElementUnderMouse, mouseEvent); } else if (evt.GetEventTypeId() == DragExitedEvent.TypeId()) { VisualElement currentTopElementUnderMouse = m_TopElementUnderMouse; m_TopElementUnderMouse = null; DispatchDragEnterDragLeave(currentTopElementUnderMouse, m_TopElementUnderMouse, mouseEvent); } // update element under mouse and fire necessary events else { VisualElement currentTopElementUnderMouse = m_TopElementUnderMouse; if (evt.target == null && panel != null) { m_TopElementUnderMouse = panel.Pick(mouseEvent.mousePosition); evt.target = m_TopElementUnderMouse; } if (evt.target != null) { eventHandled = true; PropagateEvent(evt); } if (evt.GetEventTypeId() == MouseMoveEvent.TypeId() || evt.GetEventTypeId() == MouseDownEvent.TypeId() || evt.GetEventTypeId() == MouseUpEvent.TypeId() || evt.GetEventTypeId() == MouseEnterWindowEvent.TypeId() || evt.GetEventTypeId() == WheelEvent.TypeId()) { DispatchMouseEnterMouseLeave(currentTopElementUnderMouse, m_TopElementUnderMouse, mouseEvent); DispatchMouseOverMouseOut(currentTopElementUnderMouse, m_TopElementUnderMouse, mouseEvent); } else if (evt.GetEventTypeId() == DragUpdatedEvent.TypeId()) { DispatchDragEnterDragLeave(currentTopElementUnderMouse, m_TopElementUnderMouse, mouseEvent); } } } else if (panel != null && evt is ICommandEvent) { IMGUIContainer imguiContainer = panel.focusController.focusedElement as IMGUIContainer; eventHandled = true; if (imguiContainer != null) { if (imguiContainer != evt.skipElement && imguiContainer.HandleIMGUIEvent(evt.imguiEvent)) { evt.StopPropagation(); evt.PreventDefault(); } } else if (panel.focusController.focusedElement != null) { evt.target = panel.focusController.focusedElement; PropagateEvent(evt); } else { PropagateToIMGUIContainer(panel.visualTree, evt); } } else if (evt is IPropagatableEvent || evt is IFocusEvent || evt is IChangeEvent || evt.GetEventTypeId() == InputEvent.TypeId() || evt.GetEventTypeId() == GeometryChangedEvent.TypeId()) { Debug.Assert(evt.target != null); eventHandled = true; PropagateEvent(evt); } } if (!mouseEventWasCaptured && !evt.isPropagationStopped && panel != null) { Event e = evt.imguiEvent; if (!eventHandled || (e != null && e.type == EventType.Used) || evt.GetEventTypeId() == MouseEnterWindowEvent.TypeId() || evt.GetEventTypeId() == MouseLeaveWindowEvent.TypeId()) { PropagateToIMGUIContainer(panel.visualTree, evt); } } if (evt.target == null && panel != null) { evt.target = panel.visualTree; } ExecuteDefaultAction(evt); }
protected void OnMouseCaptureOut(MouseCaptureOutEvent evt) { Focus_Mouse = false; }
private void OnMouseCaptureOut(MouseCaptureOutEvent e) { m_Active = false; }