mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Merge pull request #11791 from peppy/rooms-container-fix-click-deselection
Add the ability to deselect the currently selected room via clicking away
This commit is contained in:
commit
8e077c2857
@ -69,6 +69,20 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("last room joined", () => RoomManager.Rooms.Last().Status.Value is JoinedRoomStatus);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClickDeselection()
|
||||
{
|
||||
AddRooms(1);
|
||||
|
||||
AddAssert("no selection", () => checkRoomSelected(null));
|
||||
|
||||
press(Key.Down);
|
||||
AddAssert("first room selected", () => checkRoomSelected(RoomManager.Rooms.First()));
|
||||
|
||||
AddStep("click away", () => InputManager.Click(MouseButton.Left));
|
||||
AddAssert("no selection", () => checkRoomSelected(null));
|
||||
}
|
||||
|
||||
private void press(Key down)
|
||||
{
|
||||
AddStep($"press {down}", () => InputManager.Key(down));
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
@ -42,6 +43,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
[Resolved(CanBeNull = true)]
|
||||
private LoungeSubScreen loungeSubScreen { get; set; }
|
||||
|
||||
// handle deselection
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
public RoomsContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -165,6 +169,12 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
JoinRequested?.Invoke(selectedRoom.Value);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
selectRoom(null);
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
#region Key selection logic (shared with BeatmapCarousel)
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
|
Loading…
Reference in New Issue
Block a user