Adding a menu item

Menu items in the viewer are specified in XML files, located in the indra/newview/skins/xui/en-us/ directory.

There are separate XML files for various categories of menu. They are:

menu_viewer.xml - top of screen
menu_inventory.xml - right-click on inventory item
menu_pie_attachment.xml - right-click on your own attachment
menu_pie_avatar.xml - right-click on other avatar or their attachments
menu_pie_land.xml - right-click on land
menu_pie_self.xml - right-click on your avatar

The menu callbacks are set up in llviewermenu.cpp.

Let's add a menu item named "Foo" to the Tools menu.

<menu_item_call label="Foo" enabled="true" name="foo_menu">
  <on_click function="Tools.Foo" userdata="" />
</menu_item_call>
class LLToolsFoo : public view_listener_t
{
    bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
    {
        llinfos << "foo!" << llendl;
        return true;
    }
};
addMenu(new LLToolsFoo(), "Tools.Foo");

If you added a new source file to implement your new dialog, be sure to include it in newview/files.lst so the build system is aware of it. //If you are using Windows the file to edit is newview/CMakeLists.txt

Compile and run!