|
| | TextField (WidgetTree &tree, render::Rect bounds, TextFieldConfig config={}, WidgetId group=root) |
| | Adds the field to a tree.
|
| |
| WidgetId | id () const noexcept |
| | The field's widget in its tree.
|
| |
| const std::string & | text () const noexcept |
| | The typed text.
|
| |
| void | set_text (std::string text) |
| | Replaces the text and puts the cursor at its end.
|
| |
| std::size_t | cursor () const noexcept |
| | Where the cursor is.
|
| |
| bool | update (Navigation &navigation, const platform::TextInput &input, const platform::Keyboard &keyboard, const WidgetTree &tree) |
| | Applies the frame's input to the text.
|
| |
| void | draw (render::IRenderer &renderer, const WidgetTree &tree, const render::BitmapFont &font, const TextFieldStyle &style={}) const |
| | Draws the field, its text or placeholder and the cursor at the tree's scale.
|
| |
An editable line of text, as a widget of a WidgetTree.
The field is a widget of the tree, so it takes the focus like a button. While it is focused, the frame's typed text (platform::TextInput, so the characters follow the keyboard layout) is inserted at the cursor, up to the limit; Backspace and Delete remove one character (accents and emoji whole), Left and Right move the cursor (consumed, so the focus stays), Home and End jump to the ends, and Space types a space instead of activating. Up, Down and Tab leave the field through the tree. The caller starts the window's text input while a field is focused (Window::set_text_input()).
ui::TextField address{tree, {.x = 40, .y = 40, .width = 280, .height = 32},
{.placeholder = "server address", .max_length = 64}};
window.set_text_input(tree.focused() == address.id());
address.
update(navigation, window.text_input(), window.keyboard(), tree);
An editable line of text, as a widget of a WidgetTree.
Definition text_field.hpp:69
bool update(Navigation &navigation, const platform::TextInput &input, const platform::Keyboard &keyboard, const WidgetTree &tree)
Applies the frame's input to the text.