diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 326cb7bf..2209c4af 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -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(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(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 diff --git a/Minecraft.Client/Common/UI/UIController.h b/Minecraft.Client/Common/UI/UIController.h index 08a5ba08..fc5ee4e6 100644 --- a/Minecraft.Client/Common/UI/UIController.h +++ b/Minecraft.Client/Common/UI/UIController.h @@ -245,6 +245,7 @@ public: // INPUT private: void tickInput(); + void UpdateCursorIcon(UIControl *hitCtrl); void handleInput(); void handleKeyPress(unsigned int iPad, unsigned int key); diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp index 5cc43247..40c82dc7 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp @@ -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)