Skip to content

How to get left and right click events from a button #4317

Discussion options

You must be logged in to vote

Ui::add returns a Response. You have to assign it to a variable if you want to use it more than once.

let response = ui.add(Button::new("label"));
if response.clicked() {
    // ...
}
else if response.secondary_clicked() {
    // ...
}

Other methods are listed in the docs.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by emilk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants