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 » 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: 1077
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: Sun Jun 09 18:16:03 CEST 2024

Total time taken to generate the page: 0.01997 seconds