Answer the question
In order to leave comments, you need to log in
SDL2 Rust, how to handle button click event?
Hello.
I ran into an incident, I did not find any information about this in the documentation.
How to handle a button click on the screen?
Something similar to button.onclick() in js.
https://pastebin.com/DawvaqrG
Answer the question
In order to leave comments, you need to log in
Handle Event::MouseButtonDown event?
The examples include :
match event {
Event::Quit{..} |
Event::KeyDown {keycode: Option::Some(Keycode::Escape), ..} =>
break 'mainloop,
Event::MouseButtonDown {x, y, ..} => {
canvas.fill_rect(Rect::new(x, y, 1, 1))?;
canvas.present();
}
_ => {}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question