Fix ctrl-dragging on an existing selection causing deselection of the hovered object

This commit is contained in:
Dean Herbert
2021-04-12 19:05:23 +09:00
parent e8c248f2b2
commit cc2acf5e54
2 changed files with 60 additions and 15 deletions

View File

@ -228,12 +228,31 @@ namespace osu.Game.Screens.Edit.Compose.Components
return false;
}
if (e.ControlPressed && e.Button == MouseButton.Left)
// while holding control, we only want to add to selection, not replace an existing selection.
if (e.ControlPressed && e.Button == MouseButton.Left && !blueprint.IsSelected)
{
blueprint.ToggleSelection();
else
ensureSelected(blueprint);
return true;
}
return true;
return ensureSelected(blueprint);
}
/// <summary>
/// Handle a blueprint requesting selection.
/// </summary>
/// <param name="blueprint">The blueprint.</param>
/// <param name="e">The mouse event responsible for deselection.</param>
/// <returns>Whether a deselection was performed.</returns>
internal bool HandleDeselectionRequested(SelectionBlueprint blueprint, MouseButtonEvent e)
{
if (blueprint.IsSelected)
{
blueprint.ToggleSelection();
return true;
}
return false;
}
private void handleQuickDeletion(SelectionBlueprint blueprint)
@ -247,13 +266,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
deleteSelected();
}
private void ensureSelected(SelectionBlueprint blueprint)
/// <summary>
/// Ensure the blueprint is in a selected state.
/// </summary>
/// <param name="blueprint">The blueprint to select.</param>
/// <returns>Whether selection state was changed.</returns>
private bool ensureSelected(SelectionBlueprint blueprint)
{
if (blueprint.IsSelected)
return;
return false;
DeselectAll?.Invoke();
blueprint.Select();
return true;
}
private void deleteSelected()