Fix scrollbar rail clicking being active while popups open

Scrollbars are now also set as the hot item when the rail is hovered and the rail clicking function is now only enabled for the scrollbar that is the hot item.

Closes #8954.
This commit is contained in:
Robert Müller 2024-09-15 11:42:54 +02:00
parent dcd02b50bb
commit 8f2c288698

View file

@ -1301,21 +1301,24 @@ float CUi::DoScrollbarV(const void *pId, const CUIRect *pRect, float Current)
} }
else if(HotItem() == pId) else if(HotItem() == pId)
{ {
if(MouseButton(0)) if(InsideHandle)
{
if(MouseButton(0))
{
SetActiveItem(pId);
m_ActiveScrollbarOffset = MouseY() - Handle.y;
Grabbed = true;
}
}
else if(MouseButtonClicked(0))
{ {
SetActiveItem(pId); SetActiveItem(pId);
m_ActiveScrollbarOffset = MouseY() - Handle.y; m_ActiveScrollbarOffset = Handle.h / 2.0f;
Grabbed = true; Grabbed = true;
} }
} }
else if(MouseButtonClicked(0) && !InsideHandle && InsideRail)
{
SetActiveItem(pId);
m_ActiveScrollbarOffset = Handle.h / 2.0f;
Grabbed = true;
}
if(InsideHandle && !MouseButton(0)) if(InsideRail && !MouseButton(0))
{ {
SetHotItem(pId); SetHotItem(pId);
} }
@ -1380,19 +1383,22 @@ float CUi::DoScrollbarH(const void *pId, const CUIRect *pRect, float Current, co
} }
else if(HotItem() == pId) else if(HotItem() == pId)
{ {
if(MouseButton(0)) if(InsideHandle)
{
if(MouseButton(0))
{
SetActiveItem(pId);
m_ActiveScrollbarOffset = MouseX() - Handle.x;
Grabbed = true;
}
}
else if(MouseButtonClicked(0))
{ {
SetActiveItem(pId); SetActiveItem(pId);
m_ActiveScrollbarOffset = MouseX() - Handle.x; m_ActiveScrollbarOffset = Handle.w / 2.0f;
Grabbed = true; Grabbed = true;
} }
} }
else if(MouseButtonClicked(0) && !InsideHandle && InsideRail)
{
SetActiveItem(pId);
m_ActiveScrollbarOffset = Handle.w / 2.0f;
Grabbed = true;
}
if(!pColorInner && (InsideHandle || Grabbed) && (CheckActiveItem(pId) || HotItem() == pId)) if(!pColorInner && (InsideHandle || Grabbed) && (CheckActiveItem(pId) || HotItem() == pId))
{ {
@ -1400,7 +1406,7 @@ float CUi::DoScrollbarH(const void *pId, const CUIRect *pRect, float Current, co
Handle.y -= 1.5f; Handle.y -= 1.5f;
} }
if(InsideHandle && !MouseButton(0)) if(InsideRail && !MouseButton(0))
{ {
SetHotItem(pId); SetHotItem(pId);
} }