mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Doc, Tutorial: Fixed bug in GUI23 caused by uninitialized value.
This commit is contained in:
parent
9c0dd92628
commit
157bb81739
2 changed files with 17 additions and 3 deletions
|
|
@ -3,7 +3,7 @@
|
|||
using namespace Upp;
|
||||
|
||||
struct RandomRectCtrl : public Ctrl {
|
||||
Rect rect;
|
||||
Rect rect = Rect(Size(0, 0));
|
||||
Color color;
|
||||
|
||||
void Paint(Draw& w) override {
|
||||
|
|
@ -46,12 +46,17 @@ struct MyAppWindow : public WithMyAppLayout<TopWindow> {
|
|||
if (random_rect_ctrl.rect.IsEmpty()) {
|
||||
start_stop_btn.SetLabel("Stop!");
|
||||
|
||||
// When the user clicks the "Start" button, OnTimer() is immediately executed after
|
||||
// all related events have been processed, to generate and display a random rectangle.
|
||||
SetTimeCallback(0, [=] { OnTimer(); });
|
||||
|
||||
// Calls OnTimer() every two seconds to update the random position of a rectangle.
|
||||
SetTimeCallback(-2000, [=] { OnTimer(); });
|
||||
} else {
|
||||
KillTimeCallback();
|
||||
|
||||
start_stop_btn.SetLabel("Start!");
|
||||
random_rect_ctrl.rect = {};
|
||||
random_rect_ctrl.rect.Clear();
|
||||
random_rect_ctrl.Refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue