nwn2

Description

UIButton is an element of the NWN2's GUI which displays a button.

A simple UIButton is defined as follows:

<UIButton style="STYLE_SMALL_BUTTON" />

The above example will produce a minimalist Button. See below:

Button minimal

Attributes

Attribute Type Default value Predefined constants Description
name string none none The name of the element, used to reference it in scripts.
x int 0 ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT Horizontal coordinates in the parent element.
y int 0 ALIGN_TOP, ALIGN_CENTER, ALIGN_BOTTOM Vertical coordinates in the parent element.
width int untested PARENT_WIDTH, SCREEN_WIDTH Width of the element.
height int untested PARENT_HEIGHT, SCREEN_HEIGHT, DYNAMIC Height of the element.
style string none see Styles Predefined button styles.
text string none none Text that appears on the button.
buttontype string none radio, check Type of button.
capturemouseclicks bool true none Set if the button should react on mouse clicks.
capturemouseevents bool true none Set if the button should capture mouse events.
MouseDownSFX string none none Sound to play on the mouse down event.
MouseDragSFX string none none Sound to play on the mouse drag event.
MouseDropSFX string none none Sound to play on the mouse drop event.
MouseUpSFX string none none Sound to play on the mouse up event.
color hexadecimal none black, white, silver, gold Color of the button (untested).
disabled bool false none Set if the button is disabled.
disabledcolor hexadecimal none black, white, silver, gold Color of the button when disabled (untested).
disabledtextcolor hexadecimal none black, white, silver, gold Color of the text on the button when disabled (untested).
dontrendermousegrab bool untested none Untested.
draggable bool false none Set if the button can be moved.
fontfamily string untested see FontFamilies Set the font family to use for rendering text on the button.
groupid int none none Untested.
groupmemberid int none none Untested.
handleactiontarget bool untested none Untested.
header bool false none Set if the button is the header in a listbox (may have some over uses).
hidden bool false none Set if the button is hidden.
hotbartype string none HOTBAR_BARTER, HOTBAR_FEAT, HOTBAR_KNOWNSPELL

HOTBAR_DM_COMMAND, HOTBAR_BUTTON, HOTBAR_ITEM HOTBAR_TOGGLEMODE_BUTTON, HOTBAR_SPELL

Untested.
prototype bool false none Set if the button is the default for the parent.
repeatcallback bool false none Untested.
scalewithscene bool untested none Untested.
strref int none none Reference of the string used as text for the button (untested).
update bool false none Triggers the OnUpdate event.

Styles

The examples have been done following this definition:

<UIButton text="Example" style="STYLE_BUTTON" />
Style Description Example
STYLE_SMALL_BUTTON A simple small button Normal:Button minimal

Mouse over:Button minimal hover

On click:Button minimal onclick

STYLE_CLOSE_BUTTON A button used for closing elements

(don't use the text attribute)

Normal:Style close button

Mouse over:Style close button hover

On click:Style close button onclick

SQUARE_CHECKBOX_BUTTON A checkbox

(don't use the text attribute)

Normal:Square checkbox button

Selected:Square checkbox button active

STYLE_LIST_BUTTON A large button without background

Used in UIListBox elements

Can be in a "selected" state

Normal:

Style list button

Mouse over, Selected:

Style list button hover

On click, Selected and mouse over:

Style list button onclick

STYLE_MENU_BUTTON_SML A simple button Looks like STYLE_SMALL_BUTTON, but bigger

Normal:Style menu button sml

STYLE_SMALL_TAB Usefull for creating tabs Normal:Style small tab

Selected:Style small tab selected

STYLE_BIG_TAB Usefull for creating tabs Looks like STYLE_SMALL_TAB, but bigger

Normal:Style big tab

STYLE_EMPTY_BUTTON A small button without any layout

Used mainly as a base to define a button

Normal:Style empty button
STYLE_SKILL_ICON Usefull to display icons

Can be selected

Better to replace the text with a UIIcon.

Normal:Style skill icon

On click, Selected and mouse over:Style skill icon selected

BEHAVIOR_COLLAPSABLE_HEADER Used as the header button in UICollapsable element Behavior collapsable header
BEHAVIOR_STATE_BUTTON A round button

Reacts on clicks but doesn't seem to do anything else than playing a sound

(don't use the text attribute)

Behavior state button
BEHAVIOR_TEXT_BUTTON A simple button with no background

Used mainly as a base to create other buttons

Behavior text button
BEHAVIOR_ALL_BUTTON A simple button that acts like STYLE_SMALL_BUTTON

Used mainly as a base to create other buttons

Looks like STYLE_SMALL_BUTTON, but smaller

Normal:Behavior all button

STYLE_MENU_BUTTON A simple button Looks like STYLE_MENU_BUTTON_SML, but bigger

Normal:Style menu button

STYLE_CHARGEN_TAB A simple button with no background

Can be selected

Normal:Style chargen tab

Mouse over:Style chargen tab hover

Selected:Style chargen tab selected

STYLE_PLUS_BUTTON untested
STYLE_MINUS_BUTTON untested
STYLE_GROUP_BOX untested
STYLE_LARGE_BUTTON untested
STYLE_CHARGEN_LIST_BUTTON untested
STYLE_SKILL_TEXT untested
STYLE_LOOT_ICON untested
STYLE_LOOT_TEXT untested
CHAT_MODE_BUTTON untested
STYLE_TEXTTREE_BUTTON untested
MP_BROWSER_TAB_TITLE untested
MP_BROWSER_TAB_202 untested
MP_BROWSER_TAB_102 untested
MP_GAME_BUTTON untested
OPTIONS_BUTTON untested
MP_BROWSER_TAB_302 untested
MP_BROWSER_TAB_269 untested
SQUARE_RADIO_BUTTON untested
ROUND_RADIO_BUTTON untested
STYLE_EQUIP_BUTTON untested
STYLE_MODEBAR_BUTTON untested
OPTIONS_BUTTON_2 untested
STYLE_BUFF_BUTTON untested
PM_TOGGLE_BUTTON untested
STYLE_LIST_BUTTON_MED untested
STYLE_LIST_BUTTON_SML untested

Events

OnLeftClick

The OnLeftClick event occurs when the button is clicked with the left button of the mouse.

It is known to be usable with the following functions:

OnLeftDoubleClick

The OnLeftDoubleClick event occurs when the button is double-clicked with the left button of the mouse.

It is known to be usable with the following functions:

OnMouseDropFailed

The OnMouseDropFailed event occurs when a drop of an element on the button fails.

It is known to be usable with the following functions:

OnMouseDropReceived

The OnMouseDropReceived event occurs when an element is dropped on the button.

It is known to be usable with the following functions:

OnRadialRequest

The OnRadialRequest event occurs when the right button of the mouse is hold down on the button for a sufficent time.

It is known to be usable with the following functions:

OnRightClick

The OnRightClick event occurs when the button is clicked with the right button of the mouse.

It is known to be usable with the following functions:

OnSelected

The OnSelected event is untested.

It is known to be usable with the following functions:

OnToolTip

The OnToolTip event is untested.

It is known to be usable with the following functions:

OnUnSelected

The OnUnSelected event is untested.

It is known to be usable with the following functions:

OnUpdate

The OnUpdate event occurs when the button is updated.

It is known to be usable with the following functions:

Examples

Here is how to create a simple button, that calls a script when clicked:

<UIButton name="button" text="Button" style="STYLE_SMALL_BUTTON" OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_callback") />

More

Buttons can be used in a lot of manners, more on these later.