/// <summary> /// Trigger a dragging event when the user moves the mouse while the left mouse button is pressed /// </summary> protected override void OnMouseMove(MouseEventArgs e) { if (_userClickedThisElement && !_dragActive) { _dragActive = true; DragStart?.Invoke(this, e); } if (_dragActive) { Point curMouseScreenPos = e.GetPosition(this); if (!curMouseScreenPos.Equals(_previousMouseScreenPos)) { double xDelta = curMouseScreenPos.X - _previousMouseScreenPos.X; double yDelta = curMouseScreenPos.Y - _previousMouseScreenPos.Y; var dragEvent = new DragMoveEventArgs(e, xDelta, yDelta); DragMove?.Invoke(this, dragEvent); ApplyDragToChildren(dragEvent); _previousMouseScreenPos = curMouseScreenPos; } } base.OnMouseMove(e); }
/// <summary> /// Raises the DragStart event. /// </summary> /// <param name="mousePt">Mouse point at time of event.</param> /// <param name="offset">Offset of mouse compared to element.</param> /// <param name="c">Control that starts the drag operation.</param> protected virtual void OnDragStart(Point mousePt, Point offset, Control c) { // Convert point from client to screen coordinates mousePt = Target.OwningControl.PointToScreen(mousePt); DragStartEventCancelArgs ce = new(mousePt, offset, c); DragStart?.Invoke(this, ce); // If event is not cancelled then allow dragging _dragging = !ce.Cancel; }
/// <summary> /// Handler para this.MouseDown /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MDown(object sender, MouseEventArgs e) { // Aqui invocamos nossos eventos custom para escapar da estrutura imposta pela framework // para checar o andamento de uma operação drag & drop if (DragStart != null) { DragStart.Invoke(this, e); } this.DoDragDrop(this.Tarefa, DragDropEffects.Move); if (DragEnd != null) { DragEnd.Invoke(this, e); } }
private void StartDrag(RaycastHit forHitInfo) { if (forHitInfo.rigidbody != null && !forHitInfo.rigidbody.isKinematic) { IsDragging = true; _currentDraggable = forHitInfo.rigidbody; _initialDragValue = _currentDraggable.drag; _currentDraggable.drag = 10; _dragStartCameraPos = Camera.main.transform.position; Cursor.visible = false; Cursor.lockState = CursorLockMode.Confined; DragStart?.Invoke(_currentDraggable.gameObject); } }
private void dragField_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { DragStart?.Invoke(this, EventArgs.Empty); DragDropEffects ef = DragDrop.DoDragDrop(this, Id + "\n" + BaseString + "\n" + TranslatedString, DragDropEffects.Move); DragEnd?.Invoke(this, EventArgs.Empty); if (ef == DragDropEffects.None) { // no drop happened } else { // drop happened } } }
private void TargetWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (CanDragStart != null && !CanDragStart.Invoke()) { return; } if (hHook == IntPtr.Zero) { ptDragStart = Win32.GetCursorPos(); ptMaxDiff = new Point(0, 0); bDragStart = true; SetHook(); DragStart?.Invoke(this, new EventArgs()); } else { UnHook(); } }
private void Update() { if (EventSystem.current && EventSystem.current.currentSelectedGameObject) { return; } NormalizedDeltaInput = Vector3.zero; NormalizedGroundAlignedDeltaInput = Vector3.zero; var isInput = IsInput; switch (isInput) { case true: var inputPos = InputPos; if (_lastPos.HasValue) // Continue Drag { var delta = inputPos - _lastPos.Value; var normalizedDelta = delta / _screenWidth; Drag?.Invoke(delta); DragNormalized?.Invoke(normalizedDelta); NormalizedDeltaInput = normalizedDelta; NormalizedGroundAlignedDeltaInput = new Vector3(NormalizedDeltaInput.x, 0, NormalizedDeltaInput.y); } else // Start Drag { DragStart?.Invoke(inputPos); } _lastPos = inputPos; break; // Stop Drag case false when _lastPos.HasValue: _lastPos = null; DragEnd?.Invoke(); break; } }
public override void OnMouseButton(MouseButton button, Vector2 currentPosition, ButtonState buttonState) { if (button == MouseButton.Left) { if (buttonState == ButtonState.Pressed) { if (this.hoverable.IsHovered && !IsDragging) { IsDragging = true; this.accumulatedDragDelta = Vector2.Zero; DragStart?.Invoke(currentPosition, this.accumulatedDragDelta); } } else { if (IsDragging) { DragEnd?.Invoke(currentPosition, this.accumulatedDragDelta); } IsDragging = false; } } }
public void RaiseDragStart() { DragStart?.Invoke(this); }
private void Command_MouseDown(object sender, MouseEventArgs e) { DragStart?.Invoke(this); }
private void StartDrag() { state = DragState.Dragging; DragStart?.Invoke(); }
private void PartDidStartDrag() { DragStart?.Invoke(this); _dropPoint.gameObject.SetActive(true); }
public bool OnTouch(View view, MotionEvent motionEvent) { var action = motionEvent.Action; if (action == MotionEventActions.Down) { handler.PostDelayed(mLongPressed, 1000); var moveView = GetMovableView(view); downRawX = motionEvent.RawX; downRawY = motionEvent.RawY; dX = moveView.GetX() - downRawX; dY = moveView.GetY() - downRawY; DragStart?.Invoke(this, new FabDragEvent(dX, dY)); moveView.Animate() .ScaleX(0.6f) .ScaleY(0.6f) .SetDuration(1000) .Start(); return(true); // Consumed } if (action == MotionEventActions.Move) { handler.RemoveCallbacks(mLongPressed); var moveView = GetMovableView(view); int viewWidth = moveView.Width; int viewHeight = moveView.Height; View viewParent = (View)moveView.Parent; int parentWidth = viewParent.Width; int parentHeight = viewParent.Height; float newX = motionEvent.RawX + dX; newX = Java.Lang.Math.Max(0, newX); // Don't allow the FAB past the left hand side of the parent newX = Java.Lang.Math.Min(parentWidth - viewWidth, newX); // Don't allow the FAB past the right hand side of the parent float newY = motionEvent.RawY + dY; newY = Java.Lang.Math.Max(0, newY); // Don't allow the FAB past the top of the parent newY = Java.Lang.Math.Min(parentHeight - viewHeight, newY); // Don't allow the FAB past the bottom of the parent if (moveView.ScaleX == 1f) { moveView.Animate() .ScaleX(0.6f) .ScaleY(0.6f) .SetDuration(1000) .Start(); } moveView.Animate() .X(newX) .Y(newY) .SetDuration(0) .Start(); Dragging?.Invoke(this, new FabDragEvent(newX + moveView.Width / 2, newY + moveView.Height / 2)); return(true); // Consumed } if (action == MotionEventActions.Up) { handler.RemoveCallbacks(mLongPressed); var moveView = GetMovableView(view); float upRawX = motionEvent.RawX; float upRawY = motionEvent.RawY; float upDX = upRawX - downRawX; float upDY = upRawY - downRawY; if (Java.Lang.Math.Abs(upDX) < CLICK_DRAG_TOLERANCE && Java.Lang.Math.Abs(upDY) < CLICK_DRAG_TOLERANCE) { // A click moveView.Animate() .ScaleX(1f) .ScaleY(1f) .SetDuration(1000) .Start(); return(base.PerformClick()); } // A drag DragEnd?.Invoke(this, new FabDragEvent(moveView.GetX() + moveView.Width / 2, moveView.GetY() + moveView.Height / 2)); View viewParent = (View)moveView.Parent; moveView.Animate() .X(viewParent.Width - moveView.Width - 10) .Y(viewParent.Height - moveView.Height - 10) .SetDuration(1000) .Start(); moveView.Animate() .ScaleX(1f) .ScaleY(1f) .SetDuration(1000) .Start(); return(true); // Consumed } return(OnTouchEvent(motionEvent)); }
/// <summary> /// Raises the <see cref="E:DragStart"/> event. /// </summary> /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param> protected virtual void OnDragStart(MarkerEventArgs e) { DragStart?.Invoke(this, e); }