Gadgets API - Hello World

From Riftui Wiki

Jump to: navigation, search

This is probably the simplest Gadget you could create. It will display "Hello, Telara!" on the screen.

-- Minimalistic Gadget Example

WT.Gadget.RegisterFactory("HelloTelara",
{
	name="Hello Telara",
	description="Hello world for Rift",
	author="Wildtide",
	version="1.0.0",
	Create = 
		function(config)
			local txtHello = UI.CreateFrame("Text", "txtHello", WT.Context)
			txtHello:SetText("Hello, Telara!")
			return txtHello
		end
})

There are a few more options you can provide when registering a Gadget factory, mainly around the configuration dialogs that are available when a user creates an instance of the gadget. See WT.Gadget.RegisterFactory for more information.

The name and description should be localised using WT.Strings, rather than being hard-coded in this way, and the Create function would not usually be declared inline (creating an unnecessary closure).

However, this example demonstrates what a Gadget is, at it's most simple - it is a Frame with a small amount of configuration information attached.

Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox