Skip to content

Commit 2ee3ec7

Browse files
Potential fix for cursor not showing.
1 parent 8be6214 commit 2ee3ec7

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

SourceFiles/InputManager.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ void InputManager::OnMouseDown(int x, int y, WPARAM wParam, HWND hWnd, UINT mess
5050

5151
if (message & WM_RBUTTONDOWN)
5252
{
53-
// Hide the cursor
54-
ShowCursor(FALSE);
53+
if (m_isCursorShown)
54+
{
55+
// Hide the cursor
56+
ShowCursor(FALSE);
57+
m_isCursorShown = false;
58+
}
5559

5660
// Get the current cursor position
57-
GetCursorPos(&right_mouse_button_down_pos);
61+
GetCursorPos(&m_right_mouse_button_down_pos);
5862
}
5963

6064
SetCapture(hWnd);
@@ -65,13 +69,16 @@ void InputManager::OnMouseUp(int x, int y, WPARAM wParam, HWND hWnd, UINT messag
6569

6670
if (message & WM_RBUTTONUP)
6771
{
68-
6972
// Set the cursor position to the stored position
70-
SetCursorPos(right_mouse_button_down_pos.x, right_mouse_button_down_pos.y);
71-
}
73+
SetCursorPos(m_right_mouse_button_down_pos.x, m_right_mouse_button_down_pos.y);
7274

73-
// Show the cursor
74-
ShowCursor(TRUE);
75+
if (!m_isCursorShown)
76+
{
77+
// Show the cursor
78+
ShowCursor(TRUE);
79+
m_isCursorShown = true;
80+
}
81+
}
7582

7683
// Release the mouse input
7784
ReleaseCapture();

SourceFiles/InputManager.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class InputManager
2424

2525
private:
2626
POINT m_mouse_pos;
27-
POINT right_mouse_button_down_pos;
27+
POINT m_right_mouse_button_down_pos;
2828
std::vector<MouseMoveListener*> m_mouseMoveListeners;
29+
30+
bool m_isCursorShown = true;
2931
};

0 commit comments

Comments
 (0)