Menu with 3 level

Started by asuchi, 04 April 2019, 10:47:27

asuchi

Hello all,

I try to make a menu with 3 level ... Like  File>save>File or File>save>backup.

Tgui avec menu and item menu but i dont found the solution for my problem.

Sorry for my english ;)

billarhos

Hi

do something like that:

menu->addMenuItem({ "File", "Save", "Backup" });

asuchi

Ok, it's good to add a item... but how i do to link an action ?

I Try :
MenuBar1->connectMenuItem("File",{"File", "backup", "Action 1"},fonction1,arg);  Doesn't work
MenuBar1->connectMenuItem({"File", "backup"},"Action 1",fonction1,arg); Doesn't work
MenuBar1->connectMenuItem("File","Action 1",fonction1,arg); Doesn't work
MenuBar1->connectMenuItem("backup","Action 1",fonction1,arg); Doesn't work

I'm Loose


billarhos

One way is this

void CALLBACK menuBarClicked(tgui::MenuBar::Ptr /*menu*/)
{
// backup clicked
}
MenuBar1->connectMenuItem({ "File", "Save", "Backup" }, &menuBarClicked, MenuBar1);


or alternatively


MenuBar1->connectMenuItem({ "File", "Save", "Backup" }, [&]()
{
// backup clicked
});




asuchi

Ok thx, i will try this
thanks.

asuchi