make the demo program more interactive
This commit is contained in:
parent
e10daab4d0
commit
5744ee7add
1 changed files with 7 additions and 4 deletions
11
src/main.cpp
11
src/main.cpp
|
@ -6,10 +6,12 @@
|
||||||
#include "Label.hpp"
|
#include "Label.hpp"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
int times_clicked = 0;
|
||||||
|
|
||||||
Raven::Window window {};
|
Raven::Window window {};
|
||||||
Raven::Widget main_widget {};
|
Raven::Widget main_widget {};
|
||||||
Raven::Button button {"click me!"};
|
Raven::Button button {"click me"};
|
||||||
Raven::Label label {"you have not yet clicked the button..."};
|
Raven::Label label {"click it!"};
|
||||||
|
|
||||||
window.spawn_window();
|
window.spawn_window();
|
||||||
|
|
||||||
|
@ -20,8 +22,9 @@ int main() {
|
||||||
main_widget.set_do_background_fill(true);
|
main_widget.set_do_background_fill(true);
|
||||||
window.set_main_widget(&main_widget);
|
window.set_main_widget(&main_widget);
|
||||||
|
|
||||||
button.on_click = [&label]() {
|
button.on_click = [&label, ×_clicked]() {
|
||||||
label.set_text("you clicked it!!!!!");
|
times_clicked++;
|
||||||
|
label.set_text(std::to_string(times_clicked));
|
||||||
};
|
};
|
||||||
|
|
||||||
main_widget.add_child(&button);
|
main_widget.add_child(&button);
|
||||||
|
|
Loading…
Reference in a new issue