UI module

text_field

procedureextensionexperimentalsince 0.31.0Source

A single-line text field over edit. Returns whether the text changed and whether Enter was pressed.

Example↗
name: Text_Edit;
defer free_text_edit(*name);
ui := headless();
defer free_ui(*ui);
build := (e: *Text_Edit) {
    for column() {
        changed, submitted := text_field(e, .{ placeholder = "Your name" });
    }
};
frame(*ui, *name, build);
click(*ui, find_role(*ui, .TEXT_FIELD));
frame(*ui, *name, build);
send_text(*ui, "Ada");
frame(*ui, *name, build);
assert(contents(*name) == "Ada");
text_field :: (
    edit: *Text_Edit,
    options: Editor_Options = .{},
    loc := #caller_location
) -> (changed: bool, submitted: bool)

A single-line text field over edit. Returns whether the text changed and whether Enter was pressed.

Parameters

edit: *Text_Edit
the text being edited.
options: Editor_Options = .{}
placeholder, size and read-only mode. The font is always the sans one, with no line numbers and no growing.
loc := #caller_location
the call site. It identifies the widget from one frame to the next, so leave the default.

Returns

changed: bool
submitted: bool
Example↗
name: Text_Edit;
defer free_text_edit(*name);
ui := headless();
defer free_ui(*ui);
build := (e: *Text_Edit) {
    for column() {
        changed, submitted := text_field(e, .{ placeholder = "Your name" });
    }
};
frame(*ui, *name, build);
click(*ui, find_role(*ui, .TEXT_FIELD));
frame(*ui, *name, build);
send_text(*ui, "Ada");
frame(*ui, *name, build);
assert(contents(*name) == "Ada");

See also