Avoid using guesses to determine whether inputs blocked

This commit is contained in:
Derrick Timmermans
2021-07-18 16:04:23 +02:00
parent e35cff99c7
commit ee220feecf
2 changed files with 15 additions and 30 deletions

View File

@ -110,9 +110,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
bool selectionPerformed = performMouseDownActions(e);
// even if a selection didn't occur, a drag event may still move the selection.
prepareSelectionMovement();
bool movementPossible = prepareSelectionMovement();
return selectionPerformed || e.Button == MouseButton.Left;
return selectionPerformed || movementPossible;
}
protected SelectionBlueprint<T> ClickedBlueprint { get; private set; }
@ -427,19 +427,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary>
/// Attempts to begin the movement of any selected blueprints.
/// </summary>
private void prepareSelectionMovement()
/// <returns>Whether a movement is possible.</returns>
private bool prepareSelectionMovement()
{
if (!SelectionHandler.SelectedBlueprints.Any())
return;
return false;
// Any selected blueprint that is hovered can begin the movement of the group, however only the first item (according to SortForMovement) is used for movement.
// A special case is added for when a click selection occurred before the drag
if (!clickSelectionBegan && !SelectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
return;
return false;
// Movement is tracked from the blueprint of the earliest item, since it only makes sense to distance snap from that item
movementBlueprints = SortForMovement(SelectionHandler.SelectedBlueprints).ToArray();
movementBlueprintOriginalPositions = movementBlueprints.Select(m => m.ScreenSpaceSelectionPoint).ToArray();
return true;
}
/// <summary>