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

Missing example: mouse cursor position to render position #277

Open
ethereumdegen opened this issue Jul 29, 2023 · 0 comments
Open

Missing example: mouse cursor position to render position #277

ethereumdegen opened this issue Jul 29, 2023 · 0 comments

Comments

@ethereumdegen
Copy link

I cant figure out how to get the current mouse position and create a window/widget at the mouse position (like a windows right-click menu).

pub fn get_ui_cursor_position(window: &Window) -> Option {

   let size = Vec2::new(window.width(), window.height());

    let mut pos = window.cursor_position()? ;
   
    
    Some(Vec2::new(  pos.x,  - pos.y   ))

}

I use this and then render to the result and it KIND of works but it is offset by a weird ratio related to the window height. The X is good but the Y is totally off. Also i dont understand why I have too inverse the Y. It seems like getting the cursor position is inverted to the rendering of a window but then also skewed by the window height i am just so confused.

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