Fix right click absolute scrolling interfering with context menus

This commit is contained in:
Dean Herbert 2019-08-15 18:27:45 +09:00
parent e73a9c2748
commit 0f4bada21e
1 changed files with 32 additions and 1 deletions

View File

@ -115,7 +115,7 @@ public BeatmapCarousel()
InternalChild = new OsuContextMenuContainer InternalChild = new OsuContextMenuContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = scroll = new OsuScrollContainer Child = scroll = new CarouselScrollContainer
{ {
Masking = false, Masking = false,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -694,5 +694,36 @@ protected override void PerformSelection()
base.PerformSelection(); base.PerformSelection();
} }
} }
private class CarouselScrollContainer : OsuScrollContainer
{
private bool rightMouseScrollBlocked;
protected override bool OnMouseDown(MouseDownEvent e)
{
if (e.Button == MouseButton.Right)
{
// we need to block right click absolute scrolling when hovering a carousel item so context menus can display.
// this can be reconsidered when we have an alternative to right click scrolling.
if (GetContainingInputManager().HoveredDrawables.OfType<DrawableCarouselItem>().Any())
{
rightMouseScrollBlocked = true;
return false;
}
rightMouseScrollBlocked = false;
}
return base.OnMouseDown(e);
}
protected override bool OnDragStart(DragStartEvent e)
{
if (rightMouseScrollBlocked)
return false;
return base.OnDragStart(e);
}
}
} }
} }