Home » Community » Newbie corner » submenu of submenu
submenu of submenu [message #54932] |
Tue, 29 September 2020 14:08  |
BetoValle
Messages: 204 Registered: September 2020 Location: Brasil Valinhos SP
|
Experienced Member |
|
|
as a novice here (and also in C ++) follows a functional example for "submenu of submenu":
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
using namespace std;
struct App : public TopWindow {
bool numbers_enabled;
void Menu(Bar& bar)
{
String s="";
bar.Add("Enable numbers", [=] { numbers_enabled = !numbers_enabled; })
.Check(numbers_enabled);
bar.Sub(numbers_enabled, "Numbers", [=](Bar& bar) {
for(int i = 0; i < 10; i++) {
string s = "item "+to_string(i);
bar.Add(s, [=] { PromptOK(AsString(i)); });
}
//** starts here
bar.Sub(true,"novo",[=](Bar& bar){
bar.Add("novo item A",[=]{PromptOK("oi A");});
bar.Add("novo item B",[=]{PromptOK("oi B");});
bar.Add("novo item C",[=]{PromptOK("oi C");});
}); // important finish with "});" in new sub
}) ;
bar.Add("Exit", [=] { Close(); })
.Key(K_CTRL_E);
}
void MainBar(Bar& bar)
{
bar.Sub("Numbers", THISFN(Menu));
bar.Sub("Items", [=](Bar& bar) {
bar.Add("Item 1", [&] { Exclamation("Item 1 invoked"); });
bar.Add("Item 2", [&] { Exclamation("Item 2 invoked"); });
});
}
MenuBar menu;
typedef App CLASSNAME;
App()
{
numbers_enabled = false;
AddFrame(menu);
menu.Set(THISFN(MainBar));
}
};
GUI_APP_MAIN
{
App().Run();
}
good work U++!
[Updated on: Tue, 29 September 2020 14:52] by Moderator Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun May 11 07:06:10 CEST 2025
Total time taken to generate the page: 0.02561 seconds
|