1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Fix releasing mouse after drag deselecting dragged point

This commit is contained in:
Bartłomiej Dach 2021-12-20 21:53:51 +01:00
parent cdb587d956
commit bf8c87e9b7
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -135,9 +135,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
updateMarkerDisplay(); updateMarkerDisplay();
} }
// Used to pair up mouse down events which caused this piece to be selected // Used to pair up mouse down/drag events with their corresponding mouse up events,
// with their corresponding mouse up events. // to avoid deselecting the piece by accident when the mouse up corresponding to the mouse down/drag fires.
private bool selectionPerformed; private bool keepSelection;
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
@ -150,7 +150,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
if (!IsSelected.Value) if (!IsSelected.Value)
{ {
RequestSelection.Invoke(this, e); RequestSelection.Invoke(this, e);
selectionPerformed = true; keepSelection = true;
} }
return true; return true;
@ -169,11 +169,11 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
base.OnMouseUp(e); base.OnMouseUp(e);
// ctrl+click deselects this piece, but only if this event // ctrl+click deselects this piece, but only if this event
// wasn't immediately preceded by a matching mouse down. // wasn't immediately preceded by a matching mouse down or drag.
if (IsSelected.Value && e.ControlPressed && !selectionPerformed) if (IsSelected.Value && e.ControlPressed && !keepSelection)
IsSelected.Value = false; IsSelected.Value = false;
selectionPerformed = false; keepSelection = false;
} }
protected override bool OnClick(ClickEvent e) => RequestSelection != null; protected override bool OnClick(ClickEvent e) => RequestSelection != null;
@ -186,6 +186,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
if (e.Button == MouseButton.Left) if (e.Button == MouseButton.Left)
{ {
DragStarted?.Invoke(); DragStarted?.Invoke();
keepSelection = true;
return true; return true;
} }