U++ framework
Do not panic. Ask here before giving up.

Home » Community » U++ community news and announcements » Lambda support in MenuBar
Re: Lambda support in MenuBar [message #46613 is a reply to message #46611] Sat, 11 June 2016 12:55 Go to previous messageGo to previous message
Klugier is currently offline  Klugier
Messages: 1118
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

Solved! Just replace bar.Add with bar.Sub when the lambda sequence occurred and everything works fine.

Here is polished version of above wrong code (Maybe someone come in handy):
void WorkspaceWork::NewMenu(Bar& bar)
{
	bar.Add("File", CtrlImg::File(), [=] { NewPackageFile("New file", ""); });
	bar.Add("Separator", [=] { AddSeparator(); })
		.Help("Add text separator line");
	
	bar.Separator();
	for (int i = 0; i < categories.GetCount(); i++) {
		bar.Sub(categories.GetKey(i), [=](Bar& subBar) {
			for (FileType& fileType : categories[i]) {
				String name = fileType.GetName();
				String extension = fileType.GetExtension();
				
				if (fileType.IsSeparator())
					subBar.Separator();
				else
					subBar.Add(name, fileType.GetImage(), [=] { NewPackageFile("New " + name, extension); });
			}
		});
	}
}


Sincerely,
Klugier


U++ - one framework to rule them all.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How You will celebrate 10 000 commit of U++?
Next Topic: EditField::operator String() removed
Goto Forum:
  


Current Time: Sat Jul 11 16:52:53 GMT+2 2026

Total time taken to generate the page: 0.00625 seconds