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   |
 |
Klugier
Messages: 1099 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.
|
|
|
Goto Forum:
Current Time: Sat May 03 12:28:36 CEST 2025
Total time taken to generate the page: 0.00964 seconds
|