Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateMouseCursor overrides SFML setMouseCursorVisible(false) call #177

Open
ghost opened this issue Jul 18, 2021 · 2 comments
Open

updateMouseCursor overrides SFML setMouseCursorVisible(false) call #177

ghost opened this issue Jul 18, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 18, 2021

I have an application which has a toggle for when I'm debugging & when I'm testing and I noticed a problem with the function:

void updateMouseCursor(sf::Window& window) 

I have my mouse cursor set to hidden when testing (and all ImGui windows not set to be created) but this function kept overriding the value. I narrowed it down to the following line:

if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None) {
    window.setMouseCursorVisible(false);
} else {
    window.setMouseCursorVisible(true);

    sf::Cursor& c = s_mouseCursorLoaded[cursor] ? *s_mouseCursors[cursor] :
                                                    *s_mouseCursors[ImGuiMouseCursor_Arrow];
    window.setMouseCursor(c);
}

With the above logic if you have your ImGui IO set to not draw the cursor it takes the else branch. Do I need to set both of these values in ImGui and disregard the SFML RenderWindow function?

ImGui::SetMouseCursor(ImGuiMouseCursor_None); // used this to get round the issue
io.MouseDrawCursor = false; // this was the line that made me aware of the issue
@ghost ghost changed the title updateMouseCursor issue updateMouseCursor overrides SFML setMouseCursorVisible(false) call Jul 18, 2021
@eliasdaler
Copy link
Contributor

eliasdaler commented Aug 14, 2021

Hello
Yeah, I see no other way of handling this, unfortunately. When you set io.MouseDrawCursor to true, we definitely need to disable the cursor. And when users then set io.MouseDrawCursor to false, there's no way to recover from that properly without requiring users to manually call window.setMouseCursorVisible(true); afterwards which doesn't seem ideal to me.

If you have some idea of how changing the value io.MouseDrawCursor can be made invisible to the user (without requiring them to call window.setMouseCursorVisible(false/true); manually) , that'd be great.

@ghost
Copy link
Author

ghost commented Aug 29, 2021

I tried experimenting with it but I couldn't find a great alternative either, I guess for now calling it manually is the only way. May be worth leaving a comment about it somewhere just in case someone else runs into it. But aside from that, I can't see a better way to handle it either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant