The ListBox window element provides an automated way of viewing large tables of data without manually allocating large numbers of window elements for the display.
ListBox | The ListBox window element provides an automated way of viewing large tables of data without manually allocating large numbers of window elements for the display. |
Implementation Details | A listbox is comprised of three main components. |
XML Definition | This is the ListBox xml definition. |
XML Tag | |
Required Attributes | |
Optional Attributes | |
rowdef | The name of a Window to use as a template for each row in the display. |
scrollbar | The name of a <VerticalScrollBar> to use if the number of items in the list extends past the number of visible items. |
rowcount | The maximum number of items in the list to display. |
visiblerows | The number of rows visible on the display at a time. |
rowspacing | Size of the space to leave between rows. |
Elements | |
ListData | This element describes how the data should be displayed in each row. |
Functions | |
Functions | |
ListBoxSetDataTable() | Sets the data table to use to get the list data. |
ListBoxGetDataIndex() | Returns the data-table index that is currently display on a particular row index. |
ListBoxSetDisplayOrder() | Sets the order in which the data list is displayed. |
ListBoxSetVisibleRowCount() | Sets the maximum number of rows that can be displayed on the screen at once. |
A listbox is comprised of three main components.
The List Box will automatically populate text and icon elements within the row through the ListData binding that you set up as part of the XML definition. You can display:
DynamicImages with....
The list is populated with data from lua by the <SetDisplayOrder> function. This call allows you determine which sub-set of data you wish to display, and in which order. You can craft your own lua-sort functions to fit your specific needs.
This is the ListBox xml definition.
XML Tag | |
Required Attributes | |
Optional Attributes | |
rowdef | The name of a Window to use as a template for each row in the display. |
scrollbar | The name of a <VerticalScrollBar> to use if the number of items in the list extends past the number of visible items. |
rowcount | The maximum number of items in the list to display. |
visiblerows | The number of rows visible on the display at a time. |
rowspacing | Size of the space to leave between rows. |
Elements | |
ListData | This element describes how the data should be displayed in each row. |
The name of a <VerticalScrollBar> to use if the number of items in the list extends past the number of visible items.
A string value, which is the name of a valid <VerticalScrollBar>.
The maximum number of items in the list to display.
A number value
The number of rows visible on the display at a time.
A number value
This element describes how the data should be displayed in each row.
<ListData table="InteractionWindow.storedata" populationfunction="InteractionWindow.SetStoreItemPrices">
<ListColumns>
<ListColumn windowname="ItemPicIconBase" variable="iconNum" format="icon" />
<ListColumn windowname="ItemName" variable="name" format="wstring"/>
<ListColumn windowname="ItemCost" variable="cost" format="number" />
</ListColumns>
</ListData>
table | The name of the Lua-Table varaible that will contain the list data. |
populationfunction | An optional callback function to allow lua to modify how the rows are displayed. |
The ListColumns connect the row’s UI elements to specific data members. When the list box is updated/scrolled, these window elements are updated automatically to display the data.
windowname | The name of a child-element of the rowdef. |
varaible | The name of a lua-variable within each index of the data table. |
format | The data-type of the variable (Values: icon, wstring, number ) |
style | The style for number displays. (Values: default, comma ) |
Functions | |
ListBoxSetDataTable() | Sets the data table to use to get the list data. |
ListBoxGetDataIndex() | Returns the data-table index that is currently display on a particular row index. |
ListBoxSetDisplayOrder() | Sets the order in which the data list is displayed. |
ListBoxSetVisibleRowCount() | Sets the maximum number of rows that can be displayed on the screen at once. |
Sets the data table to use to get the list data.
editBoxName | (string) The name of the EditBox. |
dataTable | (string) The name of a valid lua table. |
nil = no return value
ListBoxSetDataTable("AbilitiesWindowAbilityList", AbilitiesWindow.moraleList )
Returns the data-table index that is currently display on a particular row index.
listBoxName | (string) The name of the ListBox. |
rowIndex | (number) The row index on the list box ( 1 -> max vis rows ) |
dataIndex | (number) The index in the ListData lua table. |
local dataIndex = ListBoxGetDataIndex("AbilitiesWindowAbilityList" )
Sets the order in which the data list is displayed. This function allows you to both sort and filter in lua.
listBoxName | (string) The name of the ListBox. |
displayOrder | (number-table) The data-indicies in the order that they should be displayed. |
nil | no return value |
local displayOrder = {}
table.insert(displayOrder, 5) -- add the 5th item from the source data table
LuaSetDisplayOrder("AbilitiesWindowAbilityList", displayOrder )
Sets the maximum number of rows that can be displayed on the screen at once.
listBoxName | (string) The name of the ListBox. |
visibleRows | (number) Sets the max number of rows to display at once. |
nil | no return value |
ListBoxSetVisibleRowCount("AbilitiesWindowAbilityList", 10 )