make the demo program more interactive

This commit is contained in:
hippoz 2022-03-29 07:08:19 +03:00
parent e10daab4d0
commit 5744ee7add
No known key found for this signature in database
GPG key ID: 7C52899193467641

View file

@ -6,10 +6,12 @@
#include "Label.hpp"
int main() {
int times_clicked = 0;
Raven::Window window {};
Raven::Widget main_widget {};
Raven::Button button {"click me!"};
Raven::Label label {"you have not yet clicked the button..."};
Raven::Button button {"click me"};
Raven::Label label {"click it!"};
window.spawn_window();
@ -20,8 +22,9 @@ int main() {
main_widget.set_do_background_fill(true);
window.set_main_widget(&main_widget);
button.on_click = [&label]() {
label.set_text("you clicked it!!!!!");
button.on_click = [&label, &times_clicked]() {
times_clicked++;
label.set_text(std::to_string(times_clicked));
};
main_widget.add_child(&button);