mirror of
https://github.com/osukey/osukey.git
synced 2025-05-17 03:27:21 +09:00
Variant 5: cannot change history, edit resets index
This commit is contained in:
parent
7dc7729ac2
commit
d81ef541bc
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -100,13 +99,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddRepeatStep("Move Up", () => InputManager.Key(Key.Up), 2);
|
AddRepeatStep("Move Up", () => InputManager.Key(Key.Up), 2);
|
||||||
AddAssert("Same as 1st message", () => box.Text == "Message 1");
|
AddAssert("Same as 1st message", () => box.Text == "Message 1");
|
||||||
|
|
||||||
AddStep("Remove text", () => box.Text = string.Empty);
|
AddStep("Change text", () => box.Text = "New message");
|
||||||
AddStep("Move Up", () => InputManager.Key(Key.Up));
|
|
||||||
AddAssert("Same as previous message", () => box.Text == "Message 2");
|
|
||||||
|
|
||||||
AddStep("Move Up", () => InputManager.Key(Key.Up));
|
|
||||||
AddStep("Select text", () => InputManager.Keys(PlatformAction.SelectAll));
|
|
||||||
AddStep("Replace text", () => box.Text = "New text");
|
|
||||||
AddStep("Move Up", () => InputManager.Key(Key.Up));
|
AddStep("Move Up", () => InputManager.Key(Key.Up));
|
||||||
AddAssert("Same as previous message", () => box.Text == "Message 2");
|
AddAssert("Same as previous message", () => box.Text == "Message 2");
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
private int selectedIndex;
|
private int selectedIndex;
|
||||||
|
|
||||||
private string originalMessage = string.Empty;
|
private string originalMessage = string.Empty;
|
||||||
private bool everythingSelected;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="HistoryTextBox"/>.
|
/// Creates a new <see cref="HistoryTextBox"/>.
|
||||||
@ -37,28 +36,13 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
Current.ValueChanged += text =>
|
Current.ValueChanged += text =>
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(text.NewValue) || everythingSelected)
|
if (selectedIndex != HistoryCount && text.NewValue != messageHistory[selectedIndex])
|
||||||
{
|
{
|
||||||
selectedIndex = HistoryCount;
|
selectedIndex = HistoryCount;
|
||||||
everythingSelected = false;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnTextDeselected()
|
|
||||||
{
|
|
||||||
base.OnTextDeselected();
|
|
||||||
|
|
||||||
everythingSelected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnTextSelectionChanged(TextSelectionType selectionType)
|
|
||||||
{
|
|
||||||
base.OnTextSelectionChanged(selectionType);
|
|
||||||
|
|
||||||
everythingSelected = SelectedText == Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
{
|
{
|
||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
@ -67,8 +51,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
if (selectedIndex == 0)
|
if (selectedIndex == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
everythingSelected = false;
|
|
||||||
|
|
||||||
if (selectedIndex == HistoryCount)
|
if (selectedIndex == HistoryCount)
|
||||||
originalMessage = Text;
|
originalMessage = Text;
|
||||||
|
|
||||||
@ -80,8 +62,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
if (selectedIndex == HistoryCount)
|
if (selectedIndex == HistoryCount)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
everythingSelected = false;
|
|
||||||
|
|
||||||
if (selectedIndex == HistoryCount - 1)
|
if (selectedIndex == HistoryCount - 1)
|
||||||
{
|
{
|
||||||
selectedIndex = HistoryCount;
|
selectedIndex = HistoryCount;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user