Skip to content

disable/enable components #390

Answered by ArthurSonzogni
Chasikanaft asked this question in Q&A
Discussion options

You must be logged in to vote

Hello!

To enable/disable an arbitrary component, you can wrap them with Maybe.
For example:

bool button_enabled = true;
auto button = Button("Disable this button ", []{
  button_enabled = false;
});
auto maybe_button = Maybe(button, &button_enabled);

To change the button's state, you can pass a reference to its state and modify it:

std::string label = "button label";
auto button = Button(&label, [&] {
  label = "new label";
});

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Chasikanaft
Comment options

@ArthurSonzogni
Comment options

@Chasikanaft
Comment options

@ArthurSonzogni
Comment options

@Chasikanaft
Comment options

Answer selected by ArthurSonzogni
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