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

Mouse Events do not trigger #491

Open
tukanoidd opened this issue Dec 24, 2021 · 1 comment
Open

Mouse Events do not trigger #491

tukanoidd opened this issue Dec 24, 2021 · 1 comment

Comments

@tukanoidd
Copy link

tukanoidd commented Dec 24, 2021

Hello, been trying to make a simple application but mouse event don't seem to have any callback whatsoever, CursorPos and MouseButton at least.

Here's my code in the while loop in match event:

WindowEvent::Key(key, scancode, action, modifiers) => {
                    if action == Action::Press {
                        if key == Key::Escape {
                            window.native_window.set_should_close(true);
                        }

                        if key == Key::E {
                            println!("E key is being pressed");
                        }
                    }
                }
                WindowEvent::CursorPos(x_pos, y_pos) => {
                    println!("Mouse Movement Event!");
                    println!("x pos: {}", x_pos);

                    if x_pos >= 800.0 {
                        println!("Mouse is at the right part of the window.")
                    }
                }
                WindowEvent::MouseButton(button, action, modifiers) => {
                    println!("Mouse Button Event!");
                    if action == Action::Press {
                        if button == MouseButtonLeft {
                            println!("Left Mouse Click!");
                        }
                    }
                }

KeyPress works without any problems, prints out the text, but no matter what I do with the mouse, nothing is getting printed out, co cursor position, no button presses.

Details:

  1. Garuda Linux, Gnome 41, X11, linux-zen 5.15.11
  2. Rust 2021 Edition
  3. Dependencies:
    1. gl - 0.14.0
    2. glfw - 0.43.0
    3. gl_generator - 0.14.0 (generating v4.6 bindings and set this version as windowHint as well)
    4. khronos_api - 3.1.0

Thanks!

@RpxdYTX
Copy link

RpxdYTX commented Jan 2, 2022

Did you call window.set_mouse_button_polling(true)? This function activates the callback that updates the mouse button events in glfw::flush_messages

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

2 participants