Skip to content

UXComboBox

UXComboBox is the editable form of a popup button. You type the text, a suggestion list narrows by case-insensitive prefix as you type, and a completion fills in the first match. The text, the suggestions and the prefix matching form a pure, testable model; the backend draws the field and runs the drop-down.

#use <UXKit>
UXComboBox* font = new UXComboBox();
font.addItem((u8*)"Helvetica");
font.addItem((u8*)"Hobo");
font.addItem((u8*)"Times");
font.setText((u8*)"H");
// completionIndex() == 0, matchCount() == 2
font.acceptCompletion(); // text is now "Helvetica"
  • Inherits UXControl: the weak: callback action, enablement, the fire path.

Suggestions · addItem · removeAllItems · count · itemAt Text · text · setText Completion · completionIndex · completion · matchCount · selectItem · acceptCompletion

void addItem(u8* s)

Appends a suggestion.

void removeAllItems(void)

Empties the suggestion list. The text, which belongs to the user, stays.

i32 count(void)

How many suggestions the list holds.

u8* itemAt(i32 i)

The suggestion’s text.

u8* text(void)

The current text, whether typed, completed or picked.

void setText(u8* s)

Replaces the text; the completion queries answer against it.

i32 completionIndex(void)

The first suggestion with the current text as a case-insensitive prefix, -1 when nothing matches or the text is empty.

u8* completion(void)

The matching suggestion’s full text, or the current text unchanged when nothing matches (a completion never destroys what was typed).

i32 matchCount(void)

How many suggestions still match the prefix. A drop-down shows these, and an autocompleting UI uses the count to decide whether completing helps.

void selectItem(i32 i)

Commits a suggestion into the text (the drop-down pick).

void acceptCompletion(void)

Commits the first match into the text (Tab completion).

UXComboBox on Web

App-drawn through the shared drawRect seam: the same rendering on every backend, captured here from this platform’s own paint path.

A tag entry that completes against the known set:

void onTagKey(UXTextField* sender) {
combo.setText(sender.text());
hint.setText(combo.matchCount() > (i32)0 ? combo.completion() : (u8*)"");
}