From 40dad37193f2ea041c346bbf9bb474ba5debfcbc Mon Sep 17 00:00:00 2001 From: NotPike <18655435+notpike@users.noreply.github.com> Date: Wed, 5 Jan 2022 19:38:44 -0500 Subject: [PATCH] Added Console --- Create-a-simple-app.md | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Create-a-simple-app.md b/Create-a-simple-app.md index f8c217a..b13c39c 100644 --- a/Create-a-simple-app.md +++ b/Create-a-simple-app.md @@ -294,6 +294,50 @@ my_progressBar.set_value(5); // 50% Complete #### Console +Console can be used as large text field where you can output mutable lines of text. Here you can find it's declaration and prototype: +``` +Console my_console_widget{ + Rect parent_rect +}; +``` + +For example, let's say you want a label called `my_console`. You will need to add this to `apps/ui_newapp.hpp`: +``` +Console my_console { + { 2*8, 10, 208, 200 }, // Coordinates are: int:x, int:y, int:width, int:height +}; +``` + +In `apps/ui_newapp.cpp` you'll need to add the `my_console` pointer to add_child() or add_children(): +``` +NewAppView::NewAppView(NavigationView &nav) { + + // Widget pointers + add_children({ + &my_console, + }); + +} +``` + +To write to 'my_console' you'll need to use the `write(std::string message)` function: +``` +my_console.write("Hello World"); +``` + +For automatic new line, you can also use the `writeln(std::string message)` function if you don't want to add a `\n' at the end of every string: +``` +my_console.writeln("Hello World but on a new line!"); +``` + +To enable scrolling you can use the `enable_scrolling(bool enable)` function:: +``` +my_console.enable_scrolling(true); +``` + + + + #### Checkbox Checkboxs are a boolean (True/False) widget that allows you chose between one of two options . Here you can find it's declaration and prototype: