ComboBox

The ComboBox provides a window-style combo box control.  This Window element is an automated combination of several other window components.

Summary
ComboBoxThe ComboBox provides a window-style combo box control.
Implementation DetailsThe ComboBox is a combination window element that automates combo-box behavior from a set of more basic window components.
XML DefinitionThis is the ComboBox xml definition.
XML Tag
Required AttributesYou need to specify valid values for all of these elements to get the ComboBox to create properly.
selectedbuttonThe name of a Button definition for the main drop-down button.
menuitembuttonThe name of a Button definition to use for each menu item in the drop down list.
menubackgroundThe name of a Window definition to use for the drop-down menu.
Optional AttributesYou can specify thesea attributes
scrollbarThe name of a VerticalScrollbar definition to be used when the combo box contains more items than can be displayed on the screen at once.
maxvisibleitemsThe maximum number of items that can be displayed on the screen at once.
Elements
MenuButtonOffsetThe offset of the menu buttons within their background.
Window CallbacksThese are the ComboBox specific callback events.
Callbacks
OnSelChangedCalled when the selected menu item is changed.
Functions
Functions
ComboBoxAddMenuItem()Adds a new item to the menu list.
ComboBoxClearMenuItems()Clears out all items currently in the menu.
ComboBoxSetSelectedMenuItem()Sets the current selected menu item
ComboBoxGetSelectedMenuItem()Returns the index of the current selected menu item
ComboBoxGetSelectedText()Returns the text of the current selected menu item
ComboBoxSetDisabledFlag()Sets if ComboBox is disabled.
ComboBoxGetDisabledFlag()Returns if the ComboBox is currently disabled.
ComboBoxIsMenuOpen()Returns if the ComboBox is currently open.
ComboBoxExternalOpenMenu()Lua-exposed function for the OpenMenu() wrapper, ExternalOpenMenu().

Implementation Details

The ComboBox is a combination window element that automates combo-box behavior from a set of more basic window components.

Components

The combo box is comprised of the following components:

  • A Button definition for the drop down button.
  • A FullResizeImage for the drop down background.
  • A Button definition for each item in the menu list.

XML Definition

This is the ComboBox xml definition.

Summary
XML Tag
Required AttributesYou need to specify valid values for all of these elements to get the ComboBox to create properly.
selectedbuttonThe name of a Button definition for the main drop-down button.
menuitembuttonThe name of a Button definition to use for each menu item in the drop down list.
menubackgroundThe name of a Window definition to use for the drop-down menu.
Optional AttributesYou can specify thesea attributes
scrollbarThe name of a VerticalScrollbar definition to be used when the combo box contains more items than can be displayed on the screen at once.
maxvisibleitemsThe maximum number of items that can be displayed on the screen at once.
Elements
MenuButtonOffsetThe offset of the menu buttons within their background.

XML Tag

<ComboBox>
....
</ComboBox>

Required Attributes

You need to specify valid values for all of these elements to get the ComboBox to create properly.

selectedbutton

The name of a Button definition for the main drop-down button.  This button def should have a text componant to display the selected menu item and the should have the drop down arrow built into it.

Expects

A string value, which is the name of a valid Button.

Default Value

  • ””

menuitembutton

The name of a Button definition to use for each menu item in the drop down list.  This button def must have a text component.

Expects

A string value, which is the name of a valid Button.

Default Value

  • ””

menubackground

The name of a Window definition to use for the drop-down menu.  The background will be sized automatically to fit the number of elements added to the menu.  This window can contain child windows, but should have anchors set up to resize correctly.

Expects

A string value, which is the name of a valid Window.

Default Value

  • ””

Optional Attributes

You can specify thesea attributes

scrollbar

The name of a VerticalScrollbar definition to be used when the combo box contains more items than can be displayed on the screen at once.

Expects

A string value, which is the name of a valid VerticalScrollbar.

Default Value

  • ””

maxvisibleitems

The maximum number of items that can be displayed on the screen at once.  If the combo box contains more than these items, the scroll bar will be shown.  If no value is specified, the ComboBox will automatically caculate a max based on how many menu buttons would fit on half of the screen height.

Expects

A number value.

Default Value

  • 0

Elements

MenuButtonOffset

The offset of the menu buttons within their background.

Syntax

<MenuButtonOffset x="10" y="10" />
xThe x-pixel offset from the top left corner of the menu background.
yThe y-pixel offset from the top left corner of the menu background.

Defaults

x0
y0

Notes

  • The menu button size will dictate the size of the background.  The offset*2 will be added to the menu background dimensions.

Window Callbacks

These are the ComboBox specific callback events.

Summary
Callbacks
OnSelChangedCalled when the selected menu item is changed.

Callbacks

OnSelChanged

Called when the selected menu item is changed.

Syntax

SomeComboBox.OnSelChanged( selectedIndex )
selectedIndex(number) The index of the newly selected item.  ( 1 through the max number of items in the menu ).

Functions

Summary
Functions
ComboBoxAddMenuItem()Adds a new item to the menu list.
ComboBoxClearMenuItems()Clears out all items currently in the menu.
ComboBoxSetSelectedMenuItem()Sets the current selected menu item
ComboBoxGetSelectedMenuItem()Returns the index of the current selected menu item
ComboBoxGetSelectedText()Returns the text of the current selected menu item
ComboBoxSetDisabledFlag()Sets if ComboBox is disabled.
ComboBoxGetDisabledFlag()Returns if the ComboBox is currently disabled.
ComboBoxIsMenuOpen()Returns if the ComboBox is currently open.
ComboBoxExternalOpenMenu()Lua-exposed function for the OpenMenu() wrapper, ExternalOpenMenu().

Functions

ComboBoxAddMenuItem()

Adds a new item to the menu list.  The first item added is at index 1, the second item added is at index 2, and so on.

Parameters

comboBoxName(string) The name of the ComboBox.
menuItemText(wstring) Text for the menu item.

Returns

nilno return value

Notes

  • none

Example

ComboBoxAddMenuItem("CareerWindowOrderCombo", L"Apprentice")
ComboBoxAddMenuItem("CareerWindowOrderCombo", L"Journeyman")
ComboBoxAddMenuItem("CareerWindowOrderCombo", L"Expert")
ComboBoxAddMenuItem("CareerWindowOrderCombo", L"Master")

ComboBoxClearMenuItems()

Clears out all items currently in the menu.

Parameters

comboBoxName(string) The name of the ComboBox.

Returns

nilno return value

Notes

  • The menu items will not be deleted until the next window update.  This function simply flags the menu items for deletion.

Example

ComboBoxClearMenuItems("CareerWindowOrderCombo")

ComboBoxSetSelectedMenuItem()

Sets the current selected menu item

Parameters

comboBoxName(string) The name of the ComboBox.
menuItemIndex(number) The index of the menu item to select.  Must be between 1 and the current number of menu items.

Returns

nilno return value

Notes

  • Setting the selected item will trigger the OnSelChanged event handler.  Make sure that you do not attempt to call ComboBoxSetSelectedMenuItem() before your event handler returns.

Example

ComboBoxSetSelectedMenuItem( "CareerWindowOrderCombo", 1 )

ComboBoxGetSelectedMenuItem()

Returns the index of the current selected menu item

Parameters

comboBoxName(string) The name of the ComboBox.

Returns

menuItemIndex(number) The index of the currently selected menu item.

Notes

  • none

Example

local curSel = ComboBoxSetSelectedMenuItem( "CareerWindowOrderCombo" )

ComboBoxGetSelectedText()

Returns the text of the current selected menu item

Parameters

comboBoxName(string) The name of the ComboBox.

Returns

menuItemText(wstring) The text of the currently selected menu item.

Notes

  • none

Example

local text = ComboBoxGetSelectedText( "CareerWindowOrderCombo" )

ComboBoxSetDisabledFlag()

Sets if ComboBox is disabled.  When disabled, the selected button will display it’s ‘disabled’ state, the drop down menu will not function.

Parameters

comboBoxName(string) The name of the ComboBox.
isDisabled.(boolean) Should the ComboBox be disabled?

Returns

nilno return value

Notes

  • Setting a ComboBox to disabled will only disable the ComoBox menu.  If you have a <OnLButtonUP> event tied to the ComboBox, that event will continue to process.

Example

ComboBoxSetDisabledFlag("GroupOptionsWindowLootModeCombo", GameData.Player.isGroupLeader == false )

ComboBoxGetDisabledFlag()

Returns if the ComboBox is currently disabled.

Parameters

comboBoxName(string) The name of the ComboBox.

Returns

isDisabled.(boolean) Is the ComboBox currently disabled?

Notes

  • none

Example

local disabled = ComboBoxGetDisabledFlag("GroupOptionsWindowLootModeCombo" )

ComboBoxIsMenuOpen()

Returns if the ComboBox is currently open.

Parameters

comboBoxName(string) The name of the ComboBox.

Returns

isOpen(boolean) Is the ComboBox currently open?

Notes

  • none

Example

local isOpen = ComboBoxIsMenuOpen("GroupOptionsWindowLootModeCombo" )

ComboBoxExternalOpenMenu()

Lua-exposed function for the OpenMenu() wrapper, ExternalOpenMenu().  Allows Lua to provide alternative ways of opening / closing the combo box.

Parameters

comboBoxName(string) The name of the ComboBox.

Returns

booltrue iff the menu was opened (i.e. it was closed previously).

Notes

  • none

Example

ComboBoxExternalOpenMenu("GroupOptionsWindowLootModeCombo")
The button element automates generic button functionality, such as swapping texture and font colors automatically according to mouse over and state.
Window is the base level window definition.
The VerticalScrollbar provides a windows-style scroll bar.
The FullResizeImage allows you to create automatically tiling images to produce backgrounds and frame.
Sets the current selected menu item