public bool InterceptMouseEvent(IPanel panel, IMouseEvent ev) { if (!m_Context.pickElement) { return(false); } var evtBase = ev as EventBase; var evtType = evtBase.eventTypeId; var target = evtBase.target as VisualElement; // Ignore events on detached elements if (panel == null) { return(false); } // Only intercept mouse clicks, MouseOverEvent and MouseEnterWindow if (evtType != MouseDownEvent.TypeId() && evtType != MouseOverEvent.TypeId() && evtType != MouseEnterWindowEvent.TypeId()) { return(false); } if (evtType == MouseDownEvent.TypeId()) { if ((ev as MouseDownEvent)?.button == (int)MouseButton.LeftMouse) { StopPicking(); } return(true); } // Ignore these events if on this debugger if (panel != m_Root.panel) { if (evtType == MouseOverEvent.TypeId()) { OnPickMouseOver(target, panel); } else if (evtType == MouseEnterWindowEvent.TypeId()) { // Focus window while picking an element var mouseOverView = GUIView.mouseOverView; if (mouseOverView != null) { mouseOverView.Focus(); } } } return(false); }
public void MouseOver(Vector2Int position) { // Does not double-click if you move your mouse more than x pixels from where you first clicked. if (Math.Abs(_lastClickPosition.x - position.x) + Math.Abs(_lastClickPosition.y - position.y) > 3) { _maxTimeForDoubleClick = 0.0f; } var x = (int)position.x - X - ParentX; var y = (int)position.y - Y - ParentY; OnMouseOver(x, y); MouseOverEvent?.Invoke(this, x, y); }
public void MouseOver(Point position) { // Does not double-click if you move your mouse more than x pixels from where you first clicked. if (Math.Abs(m_LastClickPosition.X - position.X) + Math.Abs(m_LastClickPosition.Y - position.Y) > 3) { m_MaxTimeForDoubleClick = 0.0f; } int x = (int)position.X - X - ParentX; int y = (int)position.Y - Y - ParentY; OnMouseOver(x, y); MouseOverEvent?.Invoke(this, x, y); }
private void UpdateCursorStyle(long eventType) { if (elementPanel != null) { if (eventType == MouseOverEvent.TypeId()) { elementPanel.cursorManager.SetCursor(style.cursor.value); } else { elementPanel.cursorManager.ResetCursor(); } } }
private void OnMouseOver(MouseOverEvent evt) { if (evt.button != 0) { return; } // Keep track of the graphview in case the target is removed while being hovered over. m_GraphView = (target as VisualElement).GetFirstAncestorOfType <GraphView>(); if (m_GraphView != null) { m_GraphView.currentInsertLocation = m_InsertLocation; } }
private void OnMouseOver(MouseOverEvent evt, BoxType boxType) { if (m_SelectedElement == null) { return; } m_OverlayPainter.ClearOverlay(); switch (boxType) { case BoxType.Margin: m_OverlayPainter.AddOverlay(m_SelectedElement, OverlayContent.Margin); m_MarginBox.RemoveFromClassList("box-model-white"); m_BorderBox.AddToClassList("box-model-white"); m_PaddingBox.AddToClassList("box-model-white"); m_ContentBox.AddToClassList("box-model-white"); break; case BoxType.Border: m_OverlayPainter.AddOverlay(m_SelectedElement, OverlayContent.Border); m_BorderBox.RemoveFromClassList("box-model-white"); m_MarginBox.AddToClassList("box-model-white"); m_PaddingBox.AddToClassList("box-model-white"); m_ContentBox.AddToClassList("box-model-white"); break; case BoxType.Padding: m_OverlayPainter.AddOverlay(m_SelectedElement, OverlayContent.Padding); m_MarginBox.AddToClassList("box-model-white"); m_PaddingBox.RemoveFromClassList("box-model-white"); m_BorderBox.AddToClassList("box-model-white"); m_ContentBox.AddToClassList("box-model-white"); break; case BoxType.Content: m_OverlayPainter.AddOverlay(m_SelectedElement, OverlayContent.Content); m_ContentBox.RemoveFromClassList("box-model-white"); m_MarginBox.AddToClassList("box-model-white"); m_PaddingBox.AddToClassList("box-model-white"); m_BorderBox.AddToClassList("box-model-white"); break; } m_SelectedElement.panel?.visualTree.MarkDirtyRepaint(); evt.StopPropagation(); }
private void DispatchMouseOverMouseOut(VisualElement previousTopElementUnderMouse, VisualElement currentTopElementUnderMouse, Event triggerEvent) { if (previousTopElementUnderMouse != currentTopElementUnderMouse) { if (previousTopElementUnderMouse != null) { using (MouseOutEvent pooled = MouseEventBase <MouseOutEvent> .GetPooled(triggerEvent)) { pooled.target = previousTopElementUnderMouse; this.DispatchEvent(pooled, previousTopElementUnderMouse.panel); } } if (currentTopElementUnderMouse != null) { using (MouseOverEvent pooled2 = MouseEventBase <MouseOverEvent> .GetPooled(triggerEvent)) { pooled2.target = currentTopElementUnderMouse; this.DispatchEvent(pooled2, currentTopElementUnderMouse.panel); } } } }
void SelectAllTypes(bool state, EventTypeSelection eventTypeSelection = EventTypeSelection.All) { foreach (KeyValuePair <long, bool> v in m_State.ToList()) { long eventTypeId = v.Key; if (eventTypeSelection == EventTypeSelection.All || (eventTypeSelection == EventTypeSelection.Mouse && (eventTypeId == MouseMoveEvent.TypeId() || eventTypeId == MouseOverEvent.TypeId() || eventTypeId == MouseDownEvent.TypeId() || eventTypeId == MouseUpEvent.TypeId() || eventTypeId == WheelEvent.TypeId() || eventTypeId == ContextClickEvent.TypeId())) || (eventTypeSelection == EventTypeSelection.Keyboard && (eventTypeId == KeyDownEvent.TypeId() || eventTypeId == KeyUpEvent.TypeId())) || (eventTypeSelection == EventTypeSelection.Drag && (eventTypeId == DragUpdatedEvent.TypeId() || eventTypeId == DragPerformEvent.TypeId() || eventTypeId == DragExitedEvent.TypeId())) || (eventTypeSelection == EventTypeSelection.Command && (eventTypeId == ValidateCommandEvent.TypeId() || eventTypeId == ExecuteCommandEvent.TypeId()))) { m_State[eventTypeId] = state; } else { // Unaffected should be reset to false m_State[eventTypeId] = false; } } UpdateValue(); }
protected virtual void OnMouseOver(MouseOverEvent e) { }
void UpdateEventbaseInfo(EventDebuggerEventRecord eventBase, IEventHandler focused, IEventHandler capture) { ClearEventbaseInfo(); if (eventBase == null) { return; } m_EventbaseInfo.text += "Focused element: " + EventDebugger.GetObjectDisplayName(focused) + "\n"; m_EventbaseInfo.text += "Capture element: " + EventDebugger.GetObjectDisplayName(capture) + "\n"; if (eventBase.eventTypeId == MouseMoveEvent.TypeId() || eventBase.eventTypeId == MouseOverEvent.TypeId() || eventBase.eventTypeId == MouseOutEvent.TypeId() || eventBase.eventTypeId == MouseDownEvent.TypeId() || eventBase.eventTypeId == MouseUpEvent.TypeId() || eventBase.eventTypeId == MouseEnterEvent.TypeId() || eventBase.eventTypeId == MouseLeaveEvent.TypeId() || eventBase.eventTypeId == DragEnterEvent.TypeId() || eventBase.eventTypeId == DragLeaveEvent.TypeId() || eventBase.eventTypeId == DragUpdatedEvent.TypeId() || eventBase.eventTypeId == DragPerformEvent.TypeId() || eventBase.eventTypeId == DragExitedEvent.TypeId() || eventBase.eventTypeId == ContextClickEvent.TypeId() || eventBase.eventTypeId == PointerMoveEvent.TypeId() || eventBase.eventTypeId == PointerOverEvent.TypeId() || eventBase.eventTypeId == PointerOutEvent.TypeId() || eventBase.eventTypeId == PointerDownEvent.TypeId() || eventBase.eventTypeId == PointerUpEvent.TypeId() || eventBase.eventTypeId == PointerCancelEvent.TypeId() || eventBase.eventTypeId == PointerStationaryEvent.TypeId() || eventBase.eventTypeId == PointerEnterEvent.TypeId() || eventBase.eventTypeId == PointerLeaveEvent.TypeId()) { m_EventbaseInfo.text += "Mouse position: " + eventBase.mousePosition + "\n"; m_EventbaseInfo.text += "Modifiers: " + eventBase.modifiers + "\n"; } if (eventBase.eventTypeId == KeyDownEvent.TypeId() || eventBase.eventTypeId == KeyUpEvent.TypeId()) { m_EventbaseInfo.text += "Modifiers: " + eventBase.modifiers + "\n"; } if (eventBase.eventTypeId == MouseDownEvent.TypeId() || eventBase.eventTypeId == MouseUpEvent.TypeId() || eventBase.eventTypeId == PointerDownEvent.TypeId() || eventBase.eventTypeId == PointerUpEvent.TypeId() || eventBase.eventTypeId == DragUpdatedEvent.TypeId() || eventBase.eventTypeId == DragPerformEvent.TypeId() || eventBase.eventTypeId == DragExitedEvent.TypeId()) { m_EventbaseInfo.text += "Button: " + (eventBase.button == 0 ? "Left" : eventBase.button == 1 ? "Middle" : "Right") + "\n"; m_EventbaseInfo.text += "Click count: " + eventBase.clickCount + "\n"; } if (eventBase.eventTypeId == MouseMoveEvent.TypeId() || eventBase.eventTypeId == MouseOverEvent.TypeId() || eventBase.eventTypeId == MouseOutEvent.TypeId() || eventBase.eventTypeId == MouseDownEvent.TypeId() || eventBase.eventTypeId == MouseUpEvent.TypeId() || eventBase.eventTypeId == MouseEnterEvent.TypeId() || eventBase.eventTypeId == MouseLeaveEvent.TypeId() || eventBase.eventTypeId == DragEnterEvent.TypeId() || eventBase.eventTypeId == DragLeaveEvent.TypeId() || eventBase.eventTypeId == DragUpdatedEvent.TypeId() || eventBase.eventTypeId == DragPerformEvent.TypeId() || eventBase.eventTypeId == DragExitedEvent.TypeId() || eventBase.eventTypeId == ContextClickEvent.TypeId() || eventBase.eventTypeId == WheelEvent.TypeId() || eventBase.eventTypeId == PointerMoveEvent.TypeId() || eventBase.eventTypeId == PointerOverEvent.TypeId() || eventBase.eventTypeId == PointerOutEvent.TypeId() || eventBase.eventTypeId == PointerDownEvent.TypeId() || eventBase.eventTypeId == PointerUpEvent.TypeId() || eventBase.eventTypeId == PointerCancelEvent.TypeId() || eventBase.eventTypeId == PointerStationaryEvent.TypeId() || eventBase.eventTypeId == PointerEnterEvent.TypeId() || eventBase.eventTypeId == PointerLeaveEvent.TypeId()) { m_EventbaseInfo.text += "Pressed buttons: " + eventBase.pressedButtons + "\n"; } if (eventBase.eventTypeId == WheelEvent.TypeId()) { m_EventbaseInfo.text += "Mouse delta: " + eventBase.delta + "\n"; } if (eventBase.eventTypeId == KeyDownEvent.TypeId() || eventBase.eventTypeId == KeyUpEvent.TypeId()) { if (char.IsControl(eventBase.character)) { m_EventbaseInfo.text += "Character: \\" + (byte)(eventBase.character) + "\n"; } else { m_EventbaseInfo.text += "Character: " + eventBase.character + "\n"; } m_EventbaseInfo.text += "Key code: " + eventBase.keyCode + "\n"; } if (eventBase.eventTypeId == ValidateCommandEvent.TypeId() || eventBase.eventTypeId == ExecuteCommandEvent.TypeId()) { m_EventbaseInfo.text += "Command: " + eventBase.commandName + "\n"; } }
void OnMouseEnter(MouseOverEvent evt) { localMousePosition = rootVisualElement.WorldToLocal(evt.mousePosition); }
protected internal override void OnMouseOver(MouseOverEvent e) { base.OnMouseOver(e); e.Cursor = Cursor; }
protected void OnMouseOver(MouseOverEvent e) { }
void DispatchMouseOverMouseOut(VisualElement previousTopElementUnderMouse, VisualElement currentTopElementUnderMouse, IMouseEvent triggerEvent) { if (previousTopElementUnderMouse == currentTopElementUnderMouse) { return; } // Send MouseOut event for element no longer under the mouse. if (previousTopElementUnderMouse != null && previousTopElementUnderMouse.panel != null) { using (var outEvent = (triggerEvent == null) ? MouseOutEvent.GetPooled(m_LastMousePosition) : MouseOutEvent.GetPooled(triggerEvent)) { outEvent.target = previousTopElementUnderMouse; previousTopElementUnderMouse.SendEvent(outEvent); } } // Send MouseOver event for element now under the mouse if (currentTopElementUnderMouse != null) { using (var overEvent = (triggerEvent == null) ? MouseOverEvent.GetPooled(m_LastMousePosition) : MouseOverEvent.GetPooled(triggerEvent)) { overEvent.target = currentTopElementUnderMouse; currentTopElementUnderMouse.SendEvent(overEvent); } } }