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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1775,7 +1775,7 @@ be achieved with the previously described methods.&]
|
|||
[s0;l320;C%- &]
|
||||
[s0;l320;%- [*C@(0.0.255) struct][C RandomRectCtrl ][C@(0.0.255) :][C ][*C@(0.0.255) public][C
|
||||
Ctrl `{]&]
|
||||
[s0;l320;%- [C Rect rect;]&]
|
||||
[s0;l320;%- [C Rect rect ][C@(0.0.255) `=][C Rect(Size(][C@3 0][C , ][C@3 0][C ));]&]
|
||||
[s0;l320;%- [C Color color;]&]
|
||||
[s0;l320;%- [C ]&]
|
||||
[s0;l320;%- [C ][*C@(0.0.255) void][C Paint(Draw][C@(0.0.255) `&][C w)
|
||||
|
|
@ -1832,6 +1832,15 @@ upon Ctrl destruction.]&]
|
|||
][C IsEmpty()) `{]&]
|
||||
[s0;l320;%- [C start`_stop`_btn][C@(0.0.255) .][C SetLabel(][C@3 `"Stop!`"][C );]&]
|
||||
[s0;l320;%- [C ]&]
|
||||
[s0;l320;%- [C ][/C@4 // When the user clicks the `"Start`"
|
||||
button, OnTimer() is immediately executed after]&]
|
||||
[s0;l320;%- [C ][/C@4 // all related events have been processed,
|
||||
to generate and display a random rectangle.]&]
|
||||
[s0;l320;%- [C ][*_C SetTimeCallback(][*_C@3 0][*_C , ][*_C@(0.0.255) `[`=`]][*_C
|
||||
`{ OnTimer(); `});]&]
|
||||
[s0;l320;%- [C ]&]
|
||||
[s0;l320;%- [C ][/C@4 // Calls OnTimer() every two seconds
|
||||
to update the random position of a rectangle.]&]
|
||||
[s0;l320;%- [C ][*_C SetTimeCallback(][*_C@(0.0.255) `-][*_C@3 2000][*_C ,
|
||||
][*_C@(0.0.255) `[`=`]][*_C `{ OnTimer(); `});]&]
|
||||
[s0;l320;%- [C `} ][*C@(0.0.255) else][C `{]&]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue