Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » submenu of submenu
submenu of submenu [message #54932] Tue, 29 September 2020 14:08 Go to previous message
BetoValle is currently offline  BetoValle
Messages: 203
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

 
Read Message
Read Message
Read Message
Previous Topic: VectorMap Get() on Unknow value return 23
Next Topic: double click
Goto Forum:
  


Current Time: Wed May 01 04:07:26 CEST 2024

Total time taken to generate the page: 0.02159 seconds