Adding a dialog

From Second Life Wiki
Revision as of 11:27, 3 November 2006 by James Linden (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Windows and dialogs in Second Life are implemented as LLFloater objects. The class hierarchy is:

LLFloaterFoo - a "foo" dialog
LLFloater - generic window or dialog with close box, minimize box, etc.
LLPanel - rectangular area with dark background, has functions like childSetText(), childGetValue()
LLUICtrl - any widget that can take keyboard focus
LLView - base class, container for UI widget children

Create a new C++ header and source file to hold your new class. By convention these are called llfloaterfoo.h and .cpp. Place them in the newview directory.

You'll also need a new XML description file. These are found in the indra/newview/skins/xui/en-us directory. It's easiest to copy an existing file and modify it. Name the new file floater_foo.xml.

Let's make a floater that has a text label, a text line input field, and a button.

A basic floater header looks like this:

#include "llfloater.h"
class LLFloaterFoo : public LLFloater
{
public:
    LLFloaterFoo();           // no options to constructor
    virtual ~LLFloaterFoo();
    static void show(void*);  // by convention, this shows the floater and does instance management
private:
    void onClickBar(void* userdata);   // by convention, button callbacks are named onClickButtonLabel