Skip to content

How to change the text of a button when clicked #5312

Answered by lucasmerlin
Mikachu2333 asked this question in Q&A
Discussion options

You must be logged in to vote

You'd do something like this:

let mut on_top = false;

let text = if on_top {
  "Original status (ON TOP)"
} else {
  "Status changed (NOT ON TOP)"
}

if ui.button(text).clicked() {
  on_top = !on_top;
  set_on_top(on_top);
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Mikachu2333
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