Fixed icon reseting on click

- Moved the whole icon updater snippet to a new function inside UIController so it can be called outside tickInput.
- Made a new variable inside tickInput function for the same reason.
- Modified SetCursorIcon inside KeyboardMouseInput so it gets the current icon instead of reloading the cursor.
This commit is contained in:
ACL 2026-04-17 23:33:43 +02:00
parent db8b4f6bff
commit e852392505
3 changed files with 37 additions and 20 deletions

View file

@ -792,6 +792,7 @@ void UIController::tickInput()
{
#ifdef _WINDOWS64
m_mouseClickConsumedByScene = false;
UIControl* currHitCtrl = NULL;
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
{
UIScene *pScene = nullptr;
@ -1005,24 +1006,9 @@ void UIController::tickInput()
}
}
}
// Set cursor icon based on hovered UI element (WinUser.h)
if (hitCtrl && (hitCtrl->getControlType() == UIControl::eButton || hitCtrl->getControlType() == UIControl::eButtonList))
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_HAND));
else if (hitCtrl && (hitCtrl->getControlType() == UIControl::eSlider || hitCtrl->getControlType() == UIControl::eTexturePackList))
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_SIZEWE));
else if (hitCtrl && hitCtrl->getControlType() == UIControl::eTextInput)
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_IBEAM));
else if (hitCtrl && hitCtrl->getControlType() == UIControl::eCheckBox) // Show the cross sign shaped cursor only when the checkbox is disabled/grayed out
{
UIControl_CheckBox *pCheck = static_cast<UIControl_CheckBox *>(hitCtrl);
if (pCheck && !pCheck->IsEnabled())
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_NO));
else
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_HAND));
}
else if (hitCtrl && hitCtrl->getControlType() == UIControl::eNoControl)
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_ARROW));
currHitCtrl = hitCtrl;
UpdateCursorIcon(currHitCtrl);
}
}
@ -1146,6 +1132,27 @@ void UIController::tickInput()
}
}
void UIController::UpdateCursorIcon(UIControl *hitCtrl)
{
// Set cursor icon based on hovered UI element (WinUser.h)
if (hitCtrl && (hitCtrl->getControlType() == UIControl::eButton || hitCtrl->getControlType() == UIControl::eButtonList))
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_HAND));
else if (hitCtrl && (hitCtrl->getControlType() == UIControl::eSlider || hitCtrl->getControlType() == UIControl::eTexturePackList))
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_SIZEWE));
else if (hitCtrl && hitCtrl->getControlType() == UIControl::eTextInput)
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_IBEAM));
else if (hitCtrl && hitCtrl->getControlType() == UIControl::eCheckBox) // Show the cross sign shaped cursor only when the checkbox is disabled/grayed out
{
UIControl_CheckBox *pCheck = static_cast<UIControl_CheckBox *>(hitCtrl);
if (pCheck && !pCheck->IsEnabled())
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_NO));
else
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_HAND));
}
else
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_ARROW));
}
void UIController::handleInput()
{
// For each user, loop over each key type and send messages based on the state

View file

@ -245,6 +245,7 @@ public:
// INPUT
private:
void tickInput();
void UpdateCursorIcon(UIControl *hitCtrl);
void handleInput();
void handleKeyPress(unsigned int iPad, unsigned int key);

View file

@ -392,8 +392,17 @@ float KeyboardMouseInput::GetLookY(float sensitivity) const
void KeyboardMouseInput::SetCursorIcon(LPCWSTR cursorName)
{
HCURSOR hCursor = LoadCursorW(nullptr, cursorName);
if (hCursor) SetCursor(hCursor);
HCURSOR hCursor = LoadCursorW(nullptr, cursorName);
if (hCursor)
{
SetCursor(hCursor);
if (g_hWnd)
{
// Update the cursor icon to keep the current one
SetClassLongPtrW(g_hWnd, GCLP_HCURSOR, (LONG_PTR)hCursor);
}
}
}
void KeyboardMouseInput::OnChar(wchar_t c)