Skip to content

ComboBox

This is the ComboBox class. It extends the dropdown functionality with editable text input,allowing users to either select from a list or type their own custom text.

Extends: DropDown

Properties

PropertyTypeDefaultDescription
editablebooleantrueWhether the ComboBox allows text input
textstring""The current text content of the ComboBox
cursorPosnumber1The current cursor position in the text
viewOffsetnumber0The horizontal scroll offset for viewing long text
placeholderstring"..."Text to display when input is empty
placeholderColorcolorgrayColor of the placeholder text
focusedBackgroundcolorblueBackground color when ComboBox is focused
focusedForegroundcolorwhiteForeground color when ComboBox is focused
autoCompletebooleanfalseWhether to enable auto-complete filtering when typing
manuallyOpenedbooleanfalseWhether the dropdown was manually opened (not by auto-complete)

Functions

MethodReturnsDescription
ComboBox.newComboBoxCreates a new ComboBox instance
ComboBox:setTextComboBoxSets the text content
ComboBox:getTextstringGets the text content
ComboBox:setEditableComboBoxSets editable state
ComboBox:char-Handles character input
ComboBox:key-Handles key input
ComboBox:render-Renders the ComboBox
ComboBox:focus-Called when gaining focus
ComboBox:blur-Called when losing focus

ComboBox.new()

Creates a new ComboBox instance

Returns

  • ComboBox self The newly created ComboBox instance

ComboBox:setText(text)

Sets the text content of the ComboBox

Parameters

  • text string The text to set

Returns

  • ComboBox self

ComboBox:getText()

Gets the current text content

Returns

  • string text The current text

ComboBox:setEditable(editable)

Sets whether the ComboBox is editable

Parameters

  • editable boolean Whether the ComboBox should be editable

Returns

  • ComboBox self

ComboBox:char(char)

Handles character input when editable

Parameters

  • char string The character that was typed

ComboBox:key(key, held)

Handles key input when editable

Parameters

  • key number The key code that was pressed
  • held boolean Whether the key is being held

ComboBox:render()

Renders the ComboBox

ComboBox:focus()

Called when the ComboBox gains focus

ComboBox:blur()

Called when the ComboBox loses focus

Released under the MIT License.