Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buttons receiving input outside the content #21619

Merged
merged 9 commits into from
Dec 13, 2022
Prev Previous commit
Next Next commit
Fix OsuClickableContainer input receiving
  • Loading branch information
EVAST9919 committed Dec 12, 2022
commit d2b3533356d22d3ac0350e3c8f3eb08a561413de
12 changes: 5 additions & 7 deletions osu.Game/Graphics/Containers/OsuClickableContainer.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// 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.

#nullable disable

using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterface;
using osuTK;

namespace osu.Game.Graphics.Containers
{
Expand All @@ -18,6 +17,8 @@ public partial class OsuClickableContainer : ClickableContainer, IHasTooltip

private readonly Container content = new Container { RelativeSizeAxes = Axes.Both };

public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Content.ReceivePositionalInputAt(screenSpacePos);

protected override Container<Drawable> Content => content;

protected virtual HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds(sampleSet) { Enabled = { BindTarget = Enabled } };
Expand All @@ -38,11 +39,8 @@ private void load()
content.AutoSizeAxes = AutoSizeAxes;
}

InternalChildren = new Drawable[]
{
content,
CreateHoverSounds(sampleSet)
};
AddInternal(content);
Add(CreateHoverSounds(sampleSet));
}
}
}