Text input

text_box and search_box edit a fixed capacity buffer, or a growable text_buf with no length limit. The label doubles as the empty hint. While the field has focus it edits a working copy, and writes it back and returns true on enter or when focus leaves. Escape drops the edits. search_box adds a clear mark. Text longer than UI_EDIT_MAX, 1023 bytes, shows read only and is never cut, unless the field edits a text_buf. field_ex is the same field with flags, for live edits and for handing arrow keys to a list you draw. All of them run on one edit core with undo, selection, the clipboard and IME. See text editing and IME.

A focused field edits its working copy, so a change your code makes to the buffer does not show until focus leaves. field_reload(u, id) tells the field with that id to read its buffer again on its next call, replacing the working copy, and asks for a frame. Take the id from field_out::id of a field_ex call. A search box that clears itself when Escape is pressed in a list below it is the usual case: clear the buffer, then call field_reload. It does nothing when the field is not the one being edited, since an idle field already shows the buffer.

Input, a single line text field, drawn by isolenInput, a single line text field, drawn by isolen

combo is a dropdown over a fixed list of labels. Its list is a popover on the button, so it flips and shifts to stay in the window. See portals and popovers. collapsible is a header that flips a bool*, and you declare the body after it only while it is open.

The header has the docs style fold look: a small chevron on the start side that turns from pointing along the line to pointing down as it opens, the label after it, no rules above or below, and a hover fill in the theme radius. It is a tab stop that toggles on a click, Enter or Space. In right to left the chevron sits on the right and turns the other way.

collapsible_begin(u, label, &open) gives the same header with a body that eases open and shut, a guide line down its start edge under the chevron, and the content inset to line up under the label. It returns true while the body is to be declared, including while it closes, and then you call collapsible_end(u). When it returns false it has already closed itself, so do not call the end. It is a one item accordion and lives in accordion.cpp, so calling it brings the accordion into the build.

widgets_text_input.cpp
#include "isolenui/ui/ui.h"
#include "isolenui/kit/kit.h"

struct search_state {
    char title[128] = "";
    char query[64] = "";
    uint32_t backend = 0;
    bool advanced_open = false;
};

static void search_form(ui::ctx* u, search_state* s)
{
    // text_box, a plain editable field with a label
    ui::text_box(u, "title", s->title, sizeof(s->title));

    // search_box, the same field styled with a search affordance
    ui::search_box(u, "find", s->query, sizeof(s->query));

    // combo, a dropdown that writes the chosen index back
    static const char* const backends[] = { "vulkan", "metal", "cpu" };
    ui::combo(u, "backend", backends, 3u, &s->backend);

    // collapsible, a header that toggles open on click and shows or hides
    // whatever the caller declares after it based on the bool it owns
    ui::collapsible(u, "advanced", &s->advanced_open);
    if (s->advanced_open) {
        ui::text(u, "advanced options go here", ui::caption(u));
    }
}

Last updated 6 October 2026