diff --git a/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs b/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs index b941248fa..eb8571b68 100644 --- a/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs @@ -625,8 +625,30 @@ private new void Update() UpdateCoordinates(); + UpdateDrawableObjects(); + + if (ShapeManager.IsPanning) + { + Pan(InputManager.MouseVelocity); + UpdateCenterOffset(); + } + + borderDotPen.DashOffset = (float)timerStart.Elapsed.TotalSeconds * -15; + + ShapeManager.Update(); + + if (scrollbarManager != null) + { + scrollbarManager.Update(); + } + } + + private void UpdateDrawableObjects() + { DrawableObject[] objects = DrawableObjects.OrderByDescending(x => x.Order).ToArray(); + Point position = InputManager.ClientMousePosition; + if (objects.All(x => !x.IsDragging)) { for (int i = 0; i < objects.Count(); i++) @@ -635,13 +657,13 @@ private new void Update() if (obj.Visible) { - obj.IsCursorHover = obj.Rectangle.Contains(InputManager.ClientMousePosition); + obj.IsCursorHover = obj.Rectangle.Contains(position); if (obj.IsCursorHover) { if (InputManager.IsMousePressed(MouseButtons.Left)) { - obj.OnMousePressed(); + obj.OnMousePressed(position); } for (int y = i + 1; y < objects.Count(); y++) @@ -662,26 +684,11 @@ private new void Update() { if (obj.IsDragging) { - obj.OnMouseReleased(); + obj.OnMouseReleased(position); } } } } - - if (ShapeManager.IsPanning) - { - Pan(InputManager.MouseVelocity); - UpdateCenterOffset(); - } - - borderDotPen.DashOffset = (float)timerStart.Elapsed.TotalSeconds * -15; - - ShapeManager.Update(); - - if (scrollbarManager != null) - { - scrollbarManager.Update(); - } } protected override void OnPaintBackground(PaintEventArgs e) diff --git a/ShareX.ScreenCaptureLib/RegionHelpers/DrawableObject.cs b/ShareX.ScreenCaptureLib/RegionHelpers/DrawableObject.cs index d540ac20a..2e4b34dd9 100644 --- a/ShareX.ScreenCaptureLib/RegionHelpers/DrawableObject.cs +++ b/ShareX.ScreenCaptureLib/RegionHelpers/DrawableObject.cs @@ -47,12 +47,12 @@ public virtual void OnDraw(Graphics g) } } - public virtual void OnMousePressed() + public virtual void OnMousePressed(Point position) { IsDragging = true; } - public virtual void OnMouseReleased() + public virtual void OnMouseReleased(Point position) { IsDragging = false; }