Fix inconsistent button behavior of remaining UI elements

Fix edit boxes, scrollbars, value selectors and the editor sound seekbar being activated by holding the left mouse button from outside the UI element and then hovering it, which is inconsistent with the behavior of the `DoButtonLogic` function.
This commit is contained in:
Robert Müller 2024-05-12 11:47:03 +02:00
parent d431a5cdeb
commit 1c123f2324
3 changed files with 10 additions and 9 deletions

View file

@ -798,7 +798,7 @@ bool CUi::DoEditBox(CLineInput *pLineInput, const CUIRect *pRect, float FontSize
} }
} }
if(Inside) if(Inside && !MouseButton(0))
SetHotItem(pLineInput); SetHotItem(pLineInput);
if(Enabled() && Active && !JustGotActive) if(Enabled() && Active && !JustGotActive)
@ -1013,9 +1013,6 @@ SEditResult<int64_t> CUi::DoValueSelectorWithState(const void *pId, const CUIRec
static const void *s_pEditing = nullptr; static const void *s_pEditing = nullptr;
EEditState State = EEditState::NONE; EEditState State = EEditState::NONE;
if(Inside)
SetHotItem(pId);
const int Base = Props.m_IsHex ? 16 : 10; const int Base = Props.m_IsHex ? 16 : 10;
if(MouseButtonReleased(1) && HotItem() == pId) if(MouseButtonReleased(1) && HotItem() == pId)
@ -1113,6 +1110,9 @@ SEditResult<int64_t> CUi::DoValueSelectorWithState(const void *pId, const CUIRec
DoLabel(pRect, aBuf, 10.0f, TEXTALIGN_MC); DoLabel(pRect, aBuf, 10.0f, TEXTALIGN_MC);
} }
if(Inside && !MouseButton(0))
SetHotItem(pId);
if(!m_ValueSelectorTextMode) if(!m_ValueSelectorTextMode)
s_NumberInput.Clear(); s_NumberInput.Clear();
@ -1182,7 +1182,7 @@ float CUi::DoScrollbarV(const void *pId, const CUIRect *pRect, float Current)
Grabbed = true; Grabbed = true;
} }
if(InsideHandle) if(InsideHandle && !MouseButton(0))
{ {
SetHotItem(pId); SetHotItem(pId);
} }
@ -1253,7 +1253,7 @@ float CUi::DoScrollbarH(const void *pId, const CUIRect *pRect, float Current, co
Grabbed = true; Grabbed = true;
} }
if(InsideHandle) if(InsideHandle && !MouseButton(0))
{ {
SetHotItem(pId); SetHotItem(pId);
} }

View file

@ -160,7 +160,8 @@ void CScrollRegion::End()
} }
else if(InsideSlider) else if(InsideSlider)
{ {
Ui()->SetHotItem(pId); if(!Ui()->MouseButton(0))
Ui()->SetHotItem(pId);
if(!Ui()->CheckActiveItem(pId) && Ui()->MouseButtonClicked(0)) if(!Ui()->CheckActiveItem(pId) && Ui()->MouseButtonClicked(0))
{ {

View file

@ -387,7 +387,7 @@ SEditResult<int> CEditor::UiDoValueSelector(void *pId, CUIRect *pRect, const cha
str_copy(m_aTooltip, pToolTip); str_copy(m_aTooltip, pToolTip);
} }
if(Inside) if(Inside && !Ui()->MouseButton(0))
Ui()->SetHotItem(pId); Ui()->SetHotItem(pId);
// render // render
@ -996,7 +996,7 @@ void CEditor::DoAudioPreview(CUIRect View, const void *pPlayPauseButtonId, const
Ui()->SetActiveItem(pSeekBarId); Ui()->SetActiveItem(pSeekBarId);
} }
if(Inside) if(Inside && !Ui()->MouseButton(0))
Ui()->SetHotItem(pSeekBarId); Ui()->SetHotItem(pSeekBarId);
} }
} }