Set cursor visible (windows)
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m32s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m32s
This commit is contained in:
@@ -271,11 +271,17 @@ namespace ReWindow
|
||||
void setCursorStyle(CursorStyle style) const;
|
||||
void setCursorCustomIcon() const;
|
||||
|
||||
///Hides the cursor when it's inside of our window.
|
||||
///Useful for 3D game camera.
|
||||
void setCursorVisible(bool cursor_enable);
|
||||
bool getCursorVisible();
|
||||
|
||||
/// Calls OpenGL's SwapBuffers routine.
|
||||
/// NOTE: This is only used when the underlying rendering API is set to OpenGL.
|
||||
static void glSwapBuffers();
|
||||
Vector2 getLastKnownResize() const;
|
||||
private:
|
||||
bool cursor_visible = true;
|
||||
Vector2 lastKnownWindowSize {0, 0};
|
||||
bool flags[5];
|
||||
std::vector<RWindowEvent> eventLog;
|
||||
|
@@ -48,6 +48,16 @@ Vector2 RWindow::getCursorPos() const {
|
||||
return { (float)point.x, (float)point.y };
|
||||
}
|
||||
|
||||
void RWindow::setCursorVisible(bool cursor_enable) {
|
||||
cursor_visible = cursor_enable;
|
||||
ShowCursor(cursor_visible);
|
||||
}
|
||||
|
||||
bool RWindow::getCursorVisible() {
|
||||
return cursor_visible;
|
||||
}
|
||||
|
||||
|
||||
Vector2 RWindow::getSize() const {
|
||||
RECT rect;
|
||||
GetClientRect(hwnd, &rect);
|
||||
@@ -99,6 +109,19 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
exit(0);
|
||||
case WM_SIZE:
|
||||
break;
|
||||
case WM_SETFOCUS: {
|
||||
eWindow->setFlag(RWindowFlags::IN_FOCUS, true);
|
||||
if (!eWindow->getCursorVisible())
|
||||
ShowCursor(false);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_KILLFOCUS: {
|
||||
eWindow->setFlag(RWindowFlags::IN_FOCUS, false);
|
||||
if (!eWindow->getCursorVisible())
|
||||
ShowCursor(true);
|
||||
break;
|
||||
}
|
||||
case WM_KEYDOWN: {
|
||||
auto key = GetKeyFromWindowsScancode((WindowsScancode) wParam);
|
||||
//Key repeat fix.
|
||||
|
Reference in New Issue
Block a user