mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 13:32:54 +08:00
Fix "options" button behaving weirdly when clicking on it while open
This commit is contained in:
parent
b6d6a8940b
commit
09c52f03d8
@ -188,9 +188,9 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
protected override void UpdateState(ValueChangedEvent<Visibility> state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (state.NewValue == Visibility.Hidden)
|
||||
footerButton.IsActive.Value = false;
|
||||
// intentionally scheduling to let the button have a chance whether the popover will hide from clicking the button or clicking outside
|
||||
// see the "hidingFromClick" field in FooterButtonOptionsV2.
|
||||
Schedule(() => footerButton.OverlayState.Value = state.NewValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
@ -15,7 +15,10 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
{
|
||||
public partial class FooterButtonOptionsV2 : FooterButtonV2, IHasPopover
|
||||
{
|
||||
public readonly BindableBool IsActive = new BindableBool();
|
||||
/// <summary>
|
||||
/// True if the next click is for hiding the popover.
|
||||
/// </summary>
|
||||
private bool hidingFromClick;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colour)
|
||||
@ -25,31 +28,29 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
AccentColour = colour.Purple1;
|
||||
Hotkey = GlobalAction.ToggleBeatmapOptions;
|
||||
|
||||
Action = () => IsActive.Toggle();
|
||||
Action = () =>
|
||||
{
|
||||
if (OverlayState.Value == Visibility.Hidden && !hidingFromClick)
|
||||
this.ShowPopover();
|
||||
|
||||
hidingFromClick = false;
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
base.LoadComplete();
|
||||
if (OverlayState.Value == Visibility.Visible)
|
||||
hidingFromClick = true;
|
||||
|
||||
IsActive.BindValueChanged(active =>
|
||||
{
|
||||
OverlayState.Value = active.NewValue ? Visibility.Visible : Visibility.Hidden;
|
||||
});
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
OverlayState.BindValueChanged(state =>
|
||||
{
|
||||
switch (state.NewValue)
|
||||
{
|
||||
case Visibility.Hidden:
|
||||
this.HidePopover();
|
||||
break;
|
||||
protected override void Flash()
|
||||
{
|
||||
if (hidingFromClick)
|
||||
return;
|
||||
|
||||
case Visibility.Visible:
|
||||
this.ShowPopover();
|
||||
break;
|
||||
}
|
||||
});
|
||||
base.Flash();
|
||||
}
|
||||
|
||||
public Popover GetPopover() => new BeatmapOptionsPopover(this);
|
||||
|
Loading…
Reference in New Issue
Block a user