Main Menu

menu bar

Started by Soul, 12 May 2014, 21:15:53

Soul

Hey, how i can use the same menu item names in differend menus?
something like this, when
    menu->addMenu("File");
    menu->addMenu("Layers");
    menu->addMenu("Tiles");
    menu->addMenu("Objects");
    menu->addMenuItem("File", "Create");
    menu->addMenuItem("File", "Open");
    menu->addMenuItem("File", "Save");
    menu->addMenuItem("File", "Exit");
    menu->addMenuItem("Tiles", "Create");
    menu->addMenuItem("Tiles", "Open");
    menu->addMenuItem("Tiles", "Exit");
    menu->addMenuItem("Objects", "Create");
    menu->addMenuItem("Objects", "Open");
    menu->addMenuItem("Objects", "Exit");
    menu->addMenuItem("Layers", "Tile");
    menu->addMenuItem("Layers", "Object");
    menu->addMenuItem("Layers", "Type");


when i use callback.text=="Open" only the first method will be called

texus

Quotewhen i use callback.text=="Open" only the first method will be called
I'm not sure what you mean with this.

The callback.text=="Open" should succeed for the Open item in the File, Tiles and Objects menus.
In order to identify which menu, you'll have to check callback.index as well (File will be 0, Tiles will be 2 and Objects will be 3).

I never really though that anyone would need the same string in the menu bar, so I never cared to look for a more intuitive way to handle that callback. But I did add the callback.index to make it possible.

Soul

cool this is exactly that what i needed, thanks :3