public void DispatchEvent(EventBase evt, IPanel panel) { IMouseEvent mouseEvent = evt as IMouseEvent; bool flag = DebuggerEventDispatchingStrategy.s_GlobalPanelDebug != null && mouseEvent != null; if (flag) { bool flag2 = DebuggerEventDispatchingStrategy.s_GlobalPanelDebug.InterceptMouseEvent(panel, mouseEvent); if (flag2) { evt.StopPropagation(); evt.PreventDefault(); evt.stopDispatch = true; return; } } BaseVisualElementPanel expr_4B = panel as BaseVisualElementPanel; IPanelDebug panelDebug = (expr_4B != null) ? expr_4B.panelDebug : null; bool flag3 = panelDebug != null; if (flag3) { bool flag4 = panelDebug.InterceptEvent(evt); if (flag4) { evt.StopPropagation(); evt.PreventDefault(); evt.stopDispatch = true; } } }
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 OnMouseUpDownEvent(IMouseEvent evt) { if (CanStartManipulation(evt)) { DoDisplayMenu(evt as EventBase); } }
public static T GetPooled(IMouseEvent triggerEvent) { T pooled = EventBase <T> .GetPooled(triggerEvent as EventBase); bool flag = triggerEvent != null; if (flag) { pooled.modifiers = triggerEvent.modifiers; pooled.mousePosition = triggerEvent.mousePosition; pooled.localMousePosition = triggerEvent.mousePosition; pooled.mouseDelta = triggerEvent.mouseDelta; pooled.button = triggerEvent.button; pooled.pressedButtons = triggerEvent.pressedButtons; pooled.clickCount = triggerEvent.clickCount; IMouseEventInternal mouseEventInternal = triggerEvent as IMouseEventInternal; bool flag2 = mouseEventInternal != null; if (flag2) { pooled.triggeredByOS = mouseEventInternal.triggeredByOS; pooled.recomputeTopElementUnderMouse = false; } } return(pooled); }
internal static T GetPooled(IMouseEvent triggerEvent) { T pooled = EventBase <T> .GetPooled(); bool flag = triggerEvent != null; if (flag) { pooled.pointerId = PointerId.mousePointerId; pooled.pointerType = PointerType.mouse; pooled.isPrimary = true; pooled.button = triggerEvent.button; pooled.pressedButtons = triggerEvent.pressedButtons; pooled.position = triggerEvent.mousePosition; pooled.localPosition = triggerEvent.mousePosition; pooled.deltaPosition = triggerEvent.mouseDelta; pooled.deltaTime = 0f; pooled.clickCount = triggerEvent.clickCount; pooled.pressure = ((triggerEvent.pressedButtons == 0) ? 0f : 0.5f); pooled.tangentialPressure = 0f; pooled.altitudeAngle = 0f; pooled.azimuthAngle = 0f; pooled.twist = 0f; pooled.radius = default(Vector2); pooled.radiusVariance = default(Vector2); pooled.modifiers = triggerEvent.modifiers; IMouseEventInternal mouseEventInternal = triggerEvent as IMouseEventInternal; bool flag2 = mouseEventInternal != null; if (flag2) { pooled.triggeredByOS = mouseEventInternal.triggeredByOS; } } return(pooled); }
private void _publish(IMouseEvent mouseEvent) { foreach (var e in _listeners) { e.OnEventReceived(mouseEvent); } }
private void _globalHook_MouseDragStarted(object sender, MouseEventExtArgs e) { if (_currentEvent != null) { _publish(_currentEvent); _currentEvent = null; } if (!_dragStarted) { var action = IMouseEvent.EventAction.DRAG; var ev = _toEvent(e, action); ev.Series.Add(new TimedCoordinatesImpl() { Timestamp = ev.Timestamp, X = ev.X, Y = ev.Y }); _currentEvent = ev; } _dragStarted = true; Console.WriteLine("_globalHook_MouseDragStarted"); }
static void UpdateElementUnderMouse(EventBase evt, IPanel panel, out VisualElement elementUnderMouse) { IMouseEvent mouseEvent = evt as IMouseEvent; BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel; bool shouldRecomputeTopElementUnderMouse = true; if ((IMouseEventInternal)mouseEvent != null) { shouldRecomputeTopElementUnderMouse = ((IMouseEventInternal)mouseEvent).recomputeTopElementUnderMouse; } elementUnderMouse = shouldRecomputeTopElementUnderMouse ? basePanel?.Pick(mouseEvent.mousePosition) : basePanel?.GetTopElementUnderPointer(PointerId.mousePointerId); if (basePanel != null) { // If mouse leaves the window, make sure element under mouse is null. // However, if pressed button != 0, we are getting a MouseLeaveWindowEvent as part of // of a drag and drop operation, at the very beginning of the drag. Since // we are not really exiting the window, we do not want to set the element // under mouse to null in this case. if (evt.eventTypeId == MouseLeaveWindowEvent.TypeId() && (evt as MouseLeaveWindowEvent).pressedButtons == 0) { basePanel.SetElementUnderPointer(null, evt); } else if (shouldRecomputeTopElementUnderMouse) { basePanel.SetElementUnderPointer(elementUnderMouse, evt); } } }
internal static T GetPooled(IMouseEvent triggerEvent) { T e = GetPooled(); if (triggerEvent != null) { e.pointerId = PointerId.mousePointerId; e.pointerType = PointerType.mouse; e.isPrimary = true; e.button = triggerEvent.button; e.pressedButtons = triggerEvent.pressedButtons; e.position = triggerEvent.mousePosition; e.localPosition = triggerEvent.mousePosition; e.deltaPosition = triggerEvent.mouseDelta; e.deltaTime = default; e.clickCount = triggerEvent.clickCount; e.pressure = triggerEvent.pressedButtons == 0 ? 0 : 0.5f; e.tangentialPressure = default; e.altitudeAngle = default; e.azimuthAngle = default; e.twist = default; e.radius = default; e.radiusVariance = default; e.modifiers = triggerEvent.modifiers; if (triggerEvent is IMouseEventInternal mouseEventInternal) { ((IPointerEventInternal)e).triggeredByOS = mouseEventInternal.triggeredByOS; } } return(e); }
public DropdownMenuEventInfo(EventBase e) { IMouseEvent mouseEvent = e as IMouseEvent; bool flag = mouseEvent != null; if (flag) { this.< mousePosition > k__BackingField = mouseEvent.mousePosition; this.< localMousePosition > k__BackingField = mouseEvent.localMousePosition; this.< modifiers > k__BackingField = mouseEvent.modifiers; this.< character > k__BackingField = '\0'; this.< keyCode > k__BackingField = KeyCode.None; } else { IKeyboardEvent keyboardEvent = e as IKeyboardEvent; bool flag2 = keyboardEvent != null; if (flag2) { this.< character > k__BackingField = keyboardEvent.character; this.< keyCode > k__BackingField = keyboardEvent.keyCode; this.< modifiers > k__BackingField = keyboardEvent.modifiers; this.< mousePosition > k__BackingField = Vector2.zero; this.< localMousePosition > k__BackingField = Vector2.zero; } } }
private bool HasModifiers(IMouseEvent e) { if (e == null) { return(false); } if (((modifiers & EventModifiers.Alt) != 0 && !e.altKey) || ((modifiers & EventModifiers.Alt) == 0 && e.altKey)) { return(false); } if (((modifiers & EventModifiers.Control) != 0 && !e.ctrlKey) || ((modifiers & EventModifiers.Control) == 0 && e.ctrlKey)) { return(false); } if (((modifiers & EventModifiers.Shift) != 0 && !e.shiftKey) || ((modifiers & EventModifiers.Shift) == 0 && e.shiftKey)) { return(false); } return(((modifiers & EventModifiers.Command) == 0 || e.commandKey) && ((modifiers & EventModifiers.Command) != 0 || !e.commandKey)); }
// todo: remove from here private bool TryGetButton(IMouseEvent mouseEvent, out MovieButton button) { button = MovieButton.Start; // Default var globalRay = mouseEvent.Viewport.GetGlobalRayForPixelPos(mouseEvent.State.Position); var cPlacement = Node.PresentationInfra().Placement; if (!cPlacement.PlacementSurface2D.TryFindPoint2D(globalRay, out var plainPoint)) { return(false); } var rect = Rectangle; if (plainPoint.Y > rect.MinY) { return(false); } if (((plainPoint.X - rect.MinX) % ((rect.Width - 2 * ButtonHalfWidth) / (AllMovieButtons.Length - 1))) >= 2 * ButtonHalfWidth) { return(false); } button = (MovieButton)(int)((plainPoint.X - rect.MinX) / ((rect.Width - 2 * ButtonHalfWidth) / (AllMovieButtons.Length - 1))); return(true); }
private Vector2 GetEventPointerPosition(EventBase triggerEvent) { IPointerEvent pointerEvent = triggerEvent as IPointerEvent; bool flag = pointerEvent != null; Vector2 result; if (flag) { result = new Vector2(pointerEvent.position.x, pointerEvent.position.y); } else { IMouseEvent mouseEvent = triggerEvent as IMouseEvent; bool flag2 = mouseEvent != null; if (flag2) { result = mouseEvent.mousePosition; } else { result = new Vector2(-3.40282347E+38f, -3.40282347E+38f); } } return(result); }
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); } if (((BaseVisualElementPanel)panel).ownerObject is HostView hostView && hostView.actualView is PlayModeView playModeView) { // Send event to runtime panels from closest to deepest var panels = UIElementsRuntimeUtility.GetSortedPlayerPanels(); for (var i = panels.Count - 1; i >= 0; i--) { if (SendEventToRuntimePanel((BaseRuntimePanel)panels[i], evtBase, playModeView.viewPadding, playModeView.viewMouseScale)) { return(true); } } // If no RuntimePanel catches it, select GameView editor panel and let interception fall through. if (evtType == MouseMoveEvent.TypeId() && m_Context.selectedElement != target) { OnPickMouseOver(target, panel); } }
private bool TryHandleMouseEvent(IMouseEvent eventArgs) { var pixelPos = eventArgs.Viewport.GetPixelPos(entity); var pixelDelta = eventArgs.State.Position - pixelPos; var radianDelta = (Vector2)pixelDelta / 50f; var rotation = (eventArgs.KeyModifiers & KeyModifiers.Shift) == 0 ? Quaternion.RotationX(-radianDelta.Y) * Quaternion.RotationY(-radianDelta.X) : Quaternion.RotationZ(radianDelta.X) * Quaternion.RotationY(-radianDelta.Y); var newTransform = new Transform { Scale = initialLocalTransform.Scale, Offset = initialLocalTransform.Offset, Rotation = initialLocalTransform.Rotation * rotation }; if (eventArgs.ComplexEventType == MouseEventType.Click && eventArgs.EventButtons == MouseButtons.Left) { entity.Transform = initialLocalTransform; entity.Transform = newTransform; undoRedo.OnChange(); done = true; toolService.CurrentTool = null; } else { entity.Transform = newTransform; } return(false); }
private void Init(EventBase evt) { this.eventBaseName = evt.GetType().Name; this.eventTypeId = evt.eventTypeId; this.eventId = evt.eventId; this.triggerEventId = evt.triggerEventId; this.timestamp = evt.timestamp; this.target = evt.target; this.skipElements = evt.skipElements; this.isPropagationStopped = evt.isPropagationStopped; this.isImmediatePropagationStopped = evt.isImmediatePropagationStopped; this.isDefaultPrevented = evt.isDefaultPrevented; IMouseEvent mouseEvent = evt as IMouseEvent; IMouseEventInternal mouseEventInternal = evt as IMouseEventInternal; this.hasUnderlyingPhysicalEvent = (mouseEvent != null && mouseEventInternal != null && mouseEventInternal.triggeredByOS); this.propagationPhase = evt.propagationPhase; this.originalMousePosition = evt.originalMousePosition; this.currentTarget = evt.currentTarget; this.dispatch = evt.dispatch; bool flag = mouseEvent != null; if (flag) { this.modifiers = mouseEvent.modifiers; this.mousePosition = mouseEvent.mousePosition; this.button = mouseEvent.button; this.pressedButtons = mouseEvent.pressedButtons; this.clickCount = mouseEvent.clickCount; } IPointerEvent pointerEvent = evt as IPointerEvent; IPointerEventInternal pointerEventInternal = evt as IPointerEventInternal; this.hasUnderlyingPhysicalEvent = (pointerEvent != null && pointerEventInternal != null && pointerEventInternal.triggeredByOS); bool flag2 = pointerEvent != null; if (flag2) { this.modifiers = pointerEvent.modifiers; this.mousePosition = pointerEvent.position; this.button = pointerEvent.button; this.pressedButtons = pointerEvent.pressedButtons; this.clickCount = pointerEvent.clickCount; } IKeyboardEvent keyboardEvent = evt as IKeyboardEvent; bool flag3 = keyboardEvent != null; if (flag3) { this.character = keyboardEvent.character; this.keyCode = keyboardEvent.keyCode; } ICommandEvent commandEvent = evt as ICommandEvent; bool flag4 = commandEvent != null; if (flag4) { this.commandName = commandEvent.commandName; } }
public void Remove(IMouseEvent mouseEvent) { if (_mouseEvents.Contains(mouseEvent)) { _mouseEvents.Remove(mouseEvent); } }
public static ContextualMenuPopulateEvent GetPooled(EventBase triggerEvent, ContextualMenu menu, IEventHandler target) { ContextualMenuPopulateEvent e = GetPooled(); if (triggerEvent != null) { IMouseEvent mouseEvent = triggerEvent as IMouseEvent; if (mouseEvent != null) { e.modifiers = mouseEvent.modifiers; e.mousePosition = mouseEvent.mousePosition; e.localMousePosition = mouseEvent.mousePosition; e.mouseDelta = mouseEvent.mouseDelta; e.button = mouseEvent.button; e.clickCount = mouseEvent.clickCount; } IMouseEventInternal mouseEventInternal = triggerEvent as IMouseEventInternal; if (mouseEventInternal != null) { ((IMouseEventInternal)e).hasUnderlyingPhysicalEvent = mouseEventInternal.hasUnderlyingPhysicalEvent; } e.target = target; e.menu = menu; } return(e); }
public void Add(IMouseEvent mouseEvent) { if (_mouseEvents.Contains(mouseEvent) == false) { _mouseEvents.Add(mouseEvent); } }
private void OnClickEvent(EventBase evt) { bool flag = evt.eventTypeId == EventBase <MouseUpEvent> .TypeId(); if (flag) { IMouseEvent mouseEvent = (IMouseEvent)evt; bool flag2 = mouseEvent.button == 0; if (flag2) { this.OnClick(); } } else { bool flag3 = evt.eventTypeId == EventBase <PointerUpEvent> .TypeId() || evt.eventTypeId == EventBase <ClickEvent> .TypeId(); if (flag3) { IPointerEvent pointerEvent = (IPointerEvent)evt; bool flag4 = pointerEvent.button == 0; if (flag4) { this.OnClick(); } } } }
private bool TryHandleMouse(IMouseEvent eventArgs) { if (eventArgs.ComplexEventType == MouseEventType.Move) { if (eventArgs.State.Buttons == MouseButtons.Right && eventArgs.KeyModifiers == KeyModifiers.None) { var scale = 0.00925f * realProps.GetScale(); var offset = -Vector2.UnitX * scale * eventArgs.Delta.X + Vector2.UnitY * scale * eventArgs.Delta.Y; realProps.Target += offset; EnforceBounds(); return(true); } } else if (eventArgs.ComplexEventType == MouseEventType.Wheel) { var scale = 0.1f; var distanceScale = 1f - scale * eventArgs.WheelDelta; if (eventArgs.KeyModifiers == KeyModifiers.None) { realProps.Distance *= distanceScale; } EnforceBounds(); return(true); } EnforceBounds(); return(false); }
private bool TryHandleMouseEvent(IMouseEvent args) { var rect = cText.Node.GetComponent <IRectangleComponent>().Rectangle; var textBox = cText.TextBox; if (!args.RayHitResult.HasValue) { return(false); } var hmgnPoint = args.RayHitResult.Value.LocalHitPoint.Xy; var textBoxPoint = new Vector2( (1 + hmgnPoint.X) / 2 * rect.Width * textBox.PixelScaling, (1 - hmgnPoint.Y) / 2 * rect.Height * textBox.PixelScaling); var layout = textBox.Layout; if (layout.TryGetSpanAt(textBoxPoint, out var lspan) && lspan.Embedding != null && lspan.EmbeddingHandler != null && lspan.EmbeddingHandler.TryHandleMouseEvent(lspan.Embedding, args)) { return(true); } if (args.IsLeftDownEvent()) { var newPos = layout.GetPosition(textBoxPoint); HeadlessEditor.MoveCursor(newPos, args.KeyModifiers == KeyModifiers.Shift); inputHandler.AddLock(new InputLock <object>(null, MouseDownLockProc)); return(true); } return(false); }
public void DispatchEvent(EventBase evt, IPanel panel) { IMouseEvent mouseEvent = evt as IMouseEvent; // 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" BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel; if (basePanel != null && (evt.eventTypeId == MouseLeaveWindowEvent.TypeId() || evt.eventTypeId == DragExitedEvent.TypeId())) { basePanel.SetElementUnderPointer(null, evt); } else { // update element under mouse and fire necessary events if (basePanel != null) { bool shouldRecomputeTopElementUnderMouse = true; if ((IMouseEventInternal)mouseEvent != null) { shouldRecomputeTopElementUnderMouse = ((IMouseEventInternal)mouseEvent).recomputeTopElementUnderMouse; } VisualElement elementUnderMouse = shouldRecomputeTopElementUnderMouse ? basePanel.Pick(mouseEvent.mousePosition) : basePanel.GetTopElementUnderPointer(PointerId.mousePointerId); if (evt.target == null) { evt.target = elementUnderMouse; } basePanel.SetElementUnderPointer(elementUnderMouse, evt); } if (evt.target != null) { evt.propagateToIMGUI = false; EventDispatchUtilities.PropagateEvent(evt); } } if (!evt.isPropagationStopped && panel != null) { if (evt.propagateToIMGUI || evt.eventTypeId == MouseEnterWindowEvent.TypeId() || evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ) { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } } evt.stopDispatch = true; }
/// <summary> /// Метод, выполняющий действие при перемещении мыши. /// </summary> /// <para name = "e">Переменная, хранящий данные о мыши</para> /// <para name = "Currentfigure">Переменная, хранящий данные о выбранной фигуре.</para> /// <para name = "CurrentActions">Переменная, хранящий данные о выбранном действии.</para> public List <PointF> MouseMove(MouseEventArgs e, int Currentfigure, int CurrentActions) { IMouseEvent MouseEvent = (IMouseEvent)_listIFigures[Currentfigure]; _points = MouseEvent.MouseMove(_points, e); return(_points); }
public static ContextualMenuPopulateEvent GetPooled(EventBase triggerEvent, DropdownMenu menu, IEventHandler target, ContextualMenuManager menuManager) { ContextualMenuPopulateEvent e = GetPooled(triggerEvent); if (triggerEvent != null) { triggerEvent.Acquire(); e.triggerEvent = triggerEvent; IMouseEvent mouseEvent = triggerEvent as IMouseEvent; if (mouseEvent != null) { e.modifiers = mouseEvent.modifiers; e.mousePosition = mouseEvent.mousePosition; e.localMousePosition = mouseEvent.mousePosition; e.mouseDelta = mouseEvent.mouseDelta; e.button = mouseEvent.button; e.clickCount = mouseEvent.clickCount; } IMouseEventInternal mouseEventInternal = triggerEvent as IMouseEventInternal; if (mouseEventInternal != null) { ((IMouseEventInternal)e).triggeredByOS = mouseEventInternal.triggeredByOS; } } e.target = target; e.menu = menu; e.m_ContextualMenuManager = menuManager; return(e); }
public EventInfo(EventBase e) { IMouseEvent mouseEvent = e as IMouseEvent; if (mouseEvent != null) { mousePosition = mouseEvent.mousePosition; localMousePosition = mouseEvent.localMousePosition; modifiers = mouseEvent.modifiers; character = '\0'; keyCode = KeyCode.None; } else { IKeyboardEvent keyboardEvent = e as IKeyboardEvent; if (keyboardEvent != null) { character = keyboardEvent.character; keyCode = keyboardEvent.keyCode; modifiers = keyboardEvent.modifiers; mousePosition = Vector2.zero; localMousePosition = Vector2.zero; } } }
public void DispatchEvent(EventBase evt, IPanel panel) { // s_GlobalPanelDebug handle picking elements across all panels IMouseEvent mouseEvent = evt as IMouseEvent; if (s_GlobalPanelDebug != null && mouseEvent != null) { if (s_GlobalPanelDebug.InterceptMouseEvent(panel, mouseEvent)) { evt.StopPropagation(); evt.PreventDefault(); evt.stopDispatch = true; return; } } var panelDebug = (panel as BaseVisualElementPanel)?.panelDebug; if (panelDebug != null) { if (panelDebug.InterceptEvent(evt)) { evt.StopPropagation(); evt.PreventDefault(); evt.stopDispatch = true; } } }
public bool Matches(IMouseEvent e) { // Default clickCount field value is 0 since we're in a struct -- this case is covered if the user // did not explicitly set clickCount var minClickCount = (clickCount == 0 || (e.clickCount >= clickCount)); return(button == (MouseButton)e.button && HasModifiers(e) && minClickCount); }
private bool TryHandleMouseEvent(IMouseEvent eventArgs) { if (eventArgs.ComplexEventType == MouseEventType.Click && eventArgs.EventButtons == MouseButtons.Left) { viewService.SelectedNode = Node; } return(false); }
internal void OnStartDragging(IMouseEvent evt, IEnumerable <GraphElement> elements) { if (evt.shiftKey) { Group group = parent.GetFirstAncestorOfType <Group>(); group.RemoveElements(elements); } }