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

Fix pressing Ctrl-C in composer not copying timestamp to system clipboard

This commit is contained in:
Bartłomiej Dach 2023-07-09 18:21:43 +02:00
parent 40f537ea00
commit 45194b2b4a
No known key found for this signature in database
2 changed files with 25 additions and 29 deletions

View File

@ -101,26 +101,31 @@ namespace osu.Game.Screens.Edit.Compose
#region Clipboard operations
protected override void PerformCut()
public override void Cut()
{
base.PerformCut();
if (!CanCut.Value)
return;
Copy();
EditorBeatmap.RemoveRange(EditorBeatmap.SelectedHitObjects.ToArray());
}
protected override void PerformCopy()
public override void Copy()
{
base.PerformCopy();
// on stable, pressing Ctrl-C would copy the current timestamp to system clipboard
// regardless of whether anything was even selected at all.
// UX-wise this is generally strange and unexpected, but make it work anyways to preserve muscle memory.
// note that this means that `getTimestamp()` must handle no-selection case, too.
host.GetClipboard()?.SetText(getTimestamp());
clipboard.Value = new ClipboardContent(EditorBeatmap).Serialize();
host.GetClipboard()?.SetText(formatSelectionAsString());
if (CanCopy.Value)
clipboard.Value = new ClipboardContent(EditorBeatmap).Serialize();
}
protected override void PerformPaste()
public override void Paste()
{
base.PerformPaste();
if (!CanPaste.Value)
return;
var objects = clipboard.Value.Deserialize<ClipboardContent>().HitObjects;
@ -147,7 +152,7 @@ namespace osu.Game.Screens.Edit.Compose
CanPaste.Value = composer.IsLoaded && !string.IsNullOrEmpty(clipboard.Value);
}
private string formatSelectionAsString()
private string getTimestamp()
{
if (composer == null)
return string.Empty;

View File

@ -44,29 +44,23 @@ namespace osu.Game.Screens.Edit
/// <summary>
/// Performs a "cut to clipboard" operation appropriate for the given screen.
/// </summary>
protected virtual void PerformCut()
/// <remarks>
/// Implementors are responsible for checking <see cref="CanCut"/> themselves.
/// </remarks>
public virtual void Cut()
{
}
public void Cut()
{
if (CanCut.Value)
PerformCut();
}
public BindableBool CanCopy { get; } = new BindableBool();
/// <summary>
/// Performs a "copy to clipboard" operation appropriate for the given screen.
/// </summary>
protected virtual void PerformCopy()
{
}
/// <remarks>
/// Implementors are responsible for checking <see cref="CanCopy"/> themselves.
/// </remarks>
public virtual void Copy()
{
if (CanCopy.Value)
PerformCopy();
}
public BindableBool CanPaste { get; } = new BindableBool();
@ -74,14 +68,11 @@ namespace osu.Game.Screens.Edit
/// <summary>
/// Performs a "paste from clipboard" operation appropriate for the given screen.
/// </summary>
protected virtual void PerformPaste()
{
}
/// <remarks>
/// Implementors are responsible for checking <see cref="CanPaste"/> themselves.
/// </remarks>
public virtual void Paste()
{
if (CanPaste.Value)
PerformPaste();
}
#endregion