diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-04 19:07:55 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-04 21:04:06 +0100 |
commit | 028c011760b5b665fc2a72bb3c11fd3a6ca60d2c (patch) | |
tree | a961293992de78ebac5c3ffec864179d661dcc09 /Demos/HelloWorld/main.cpp | |
parent | fb09b6a8cec02cc473b3fed326d99055d80a60ba (diff) | |
download | serenity-028c011760b5b665fc2a72bb3c11fd3a6ca60d2c.zip |
LibCore: Make Core::Object::add<ChildType> return a ChildType&
Since the returned object is now owned by the callee object, we can
simply vend a ChildType&. This allows us to use "." instead of "->"
at the call site, which is quite nice. :^)
Diffstat (limited to 'Demos/HelloWorld/main.cpp')
-rw-r--r-- | Demos/HelloWorld/main.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Demos/HelloWorld/main.cpp b/Demos/HelloWorld/main.cpp index 14614c00ce..7bbe69a1dc 100644 --- a/Demos/HelloWorld/main.cpp +++ b/Demos/HelloWorld/main.cpp @@ -45,14 +45,14 @@ int main(int argc, char** argv) auto& layout = main_widget.set_layout<GUI::VerticalBoxLayout>(); layout.set_margins({ 4, 4, 4, 4 }); - auto label = main_widget.add<GUI::Label>(); - label->set_text("Hello\nWorld!"); - - auto button = main_widget.add<GUI::Button>(); - button->set_text("Good-bye"); - button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); - button->set_preferred_size(0, 20); - button->on_click = [&] { + auto& label = main_widget.add<GUI::Label>(); + label.set_text("Hello\nWorld!"); + + auto& button = main_widget.add<GUI::Button>(); + button.set_text("Good-bye"); + button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); + button.set_preferred_size(0, 20); + button.on_click = [&] { app.quit(); }; |