Skip to content

ComboBox

coding.jackalope edited this page Apr 29, 2019 · 4 revisions
Table of Contents

Overview

A combo box allows the user to select a single item from a list and display the selected item in the combo box. The list is only visible when the user is interacting with the control.

local Fruits = {"Apple", "Banana", "Orange", "Pear", "Lemon"}
local Selected = ""

Slab.BeginWindow('MyFirstWindow', {Title = "My First Window"})

if Slab.BeginComboBox('MyComboBox', {Selected = Selected}) then
	for I, V in ipairs(Fruits) do
		if Slab.TextSelectable(V) then
			Selected = V
		end
	end

	Slab.EndComboBox()
end

Slab.EndWindow()

API

Below is a list of functions associated with the Combo Box API.

BeginComboBox

This function renders a non-editable input field with a drop down arrow. When the user clicks this option, a window is created and the user can supply their own Slab.TextSelectable calls to add possible items to select from. This function will return true if the combo box is opened. Slab.EndComboBox must be called if this function returns true.

Parameter Type Description
Id String A string that uniquely identifies this combo box within the context of the active window.
Options Table List of options that control how this combo box behaves.
Option Type Description
Tooltip String Text that is rendered when the user hovers over this combo box.
Selected String Text that is displayed in the non-editable input box for this combo box.
W Number The width of the combo box. The default value is 150.0.
Rounding Number Amount of rounding to apply to the corners of the combo box.
Return Description
Boolean This function will return true if the combo box is open.

EndComboBox

Finishes up any BeginComboBox calls if those functions return true.

Clone this wiki locally