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

How can I prevent the cursor from moving out of the window? #2122

Closed
ghost opened this issue Jan 1, 2022 · 5 comments
Closed

How can I prevent the cursor from moving out of the window? #2122

ghost opened this issue Jan 1, 2022 · 5 comments
Labels
DS - macos F - question There's no such thing as a stupid one

Comments

@ghost
Copy link

ghost commented Jan 1, 2022

I'm a mac user using maxos 12.1.

How can I prevent the cursor from going off the screen?

In my experience with other screen libraries I think there is such an option, but I couldn't find it in the docs.

@madsmtm
Copy link
Member

madsmtm commented Jan 1, 2022

Window::set_cursor_grab might be what you are looking for.

This doesn't work the web, though it probably could, see #1674

@ghost
Copy link
Author

ghost commented Jan 1, 2022

@madsmtm
Thank you for your comment.

I've already tried this feature, but it wasn't what I was looking for.

You may have misunderstood the specifications of Window :: set_cursor_grab, so I'd like to ask you just in case.
Is this a function that allows the cursor to move within the screen?

In my environment, when I used Window::set_cursor_grab, the cursor didn't move in the screen, so I couldn't understand the purpose of this function.

@maroider maroider added DS - macos F - question There's no such thing as a stupid one labels Jan 2, 2022
@ghost
Copy link
Author

ghost commented Jan 2, 2022

I'm sorry, I was misunderstanding.

As a workaround for # 1470, I also used WindowEvent for mouse events, so it seems that the cursor did not move within the screen even when using Window :: set_cursor_grab.

I solved it by using DeviceEvent for mouse events.

@maroider
Copy link
Member

maroider commented Jan 2, 2022

In my environment, when I used Window::set_cursor_grab, the cursor didn't move in the screen, so I couldn't understand the purpose of this function.

This is a known (and documented) limitation with Window::set_cursor_grab on macOS. It lets you move the cursor around on Linux and Windows.

@ghost
Copy link
Author

ghost commented Jan 2, 2022

@maroider

Sorry.
I thought I was reading the docs, but looking only at the content here, I didn't think the cursor would move on the screen when using DeviceEvent, so I thought it was a strange feature.
https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_cursor_grab

@ghost ghost closed this as completed Jan 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DS - macos F - question There's no such thing as a stupid one
Development

No branches or pull requests

2 participants