xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
main_menu_create_standard_items.cpp

The following code example demonstrate the use of main_menu::create_standard_items factory.

Windows
main_menu_create_standard_items_w.png

main_menu_create_standard_itemsmain_menu_create_standard_items_wd.png
macOS
main_menu_create_standard_items_m.png

main_menu_create_standard_items_md.png
Gnome
main_menu_create_standard_items_g.png

main_menu_create_standard_items_gd.png
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::forms;
namespace examples {
class form1 : public form {
public:
form1() {
text("Main menu create standard items example");
menu(main_menu::create_standard_items([&](object& sender, const event_args& e) {
list_box1.items().push_back(ustring::format("{} clicked", as<menu_item&>(sender).text()));
list_box1.selected_index(list_box1.items().size() - 1);
if (as<menu_item&>(sender).text() == system_texts::exit()) application::exit();
}));
list_box1.parent(*this);
list_box1.dock(dock_style::fill);
}
private:
list_box list_box1;
};
}
int main() {
application::run(examples::form1());
}