From 5744ee7add188c05e07f2ffe65c0a5cf1906c5b1 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Tue, 29 Mar 2022 07:08:19 +0300 Subject: [PATCH] make the demo program more interactive --- src/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 918cd63..4ba1994 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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, ×_clicked]() { + times_clicked++; + label.set_text(std::to_string(times_clicked)); }; main_widget.add_child(&button);