-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21614 from EVAST9919/button-fix
Fix SettingsButton receiving input at padded area
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
osu.Game.Tests/Visual/UserInterface/TestSceneSettingsButton.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics; | ||
using osu.Game.Overlays.Settings; | ||
using NUnit.Framework; | ||
using osuTK; | ||
using osu.Game.Overlays; | ||
|
||
namespace osu.Game.Tests.Visual.UserInterface | ||
{ | ||
public partial class TestSceneSettingsButton : OsuManualInputManagerTestScene | ||
{ | ||
private readonly SettingsButton settingsButton; | ||
|
||
public TestSceneSettingsButton() | ||
{ | ||
Add(new Container | ||
{ | ||
AutoSizeAxes = Axes.Y, | ||
Width = 500, | ||
Child = settingsButton = new SettingsButton | ||
{ | ||
Enabled = { Value = true }, | ||
Text = "Test settings button" | ||
} | ||
}); | ||
} | ||
|
||
[Test] | ||
public void TestInputAtPaddedArea() | ||
{ | ||
AddStep("Move cursor to button", () => InputManager.MoveMouseTo(settingsButton)); | ||
AddAssert("Button is hovered", () => settingsButton.IsHovered); | ||
AddStep("Move cursor to padded area", () => InputManager.MoveMouseTo(settingsButton.ScreenSpaceDrawQuad.TopLeft + new Vector2(SettingsPanel.CONTENT_MARGINS / 2f, 10))); | ||
AddAssert("Cursor within a button", () => settingsButton.ScreenSpaceDrawQuad.Contains(InputManager.CurrentState.Mouse.Position)); | ||
AddAssert("Button is not hovered", () => !settingsButton.IsHovered); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters