Function draw_text_input

Source
pub fn draw_text_input(
    rect: Rect,
    text: &str,
    caret_byte: usize,
    selection: Option<Selection>,
    preedit: Option<&ImePreedit>,
    focused: bool,
    now_ms: i64,
    style: TextInputStyle,
    text_system: &mut TextSystem,
) -> Vec<DrawCmd>
Expand description

Draws one legacy single-line text input into newly owned commands.

Paint order is background, border, optional selection, glyphs, then optional caret. caret_byte and [Selection] offsets use UTF-8 bytes and are length-clamped. Selection is omitted during IME preedit. A focused caret is visible on even now_ms / caret_blink_ms half-periods; non-positive cadence suppresses it. This helper does not clip horizontally or draw placeholder text and performs no event handling.

§Panics

Panics when a non-empty preedit is inserted at a clamped caret_byte that is not a UTF-8 character boundary.

§Examples

use ailloli_ui_core::Rect;
use ailloli_ui_text::TextSystem;
use ailloli_ui_widgets::controls::text_input::draw_text_input;
use ailloli_ui_widgets::controls::TextInputStyle;
let mut text = TextSystem::new();
let commands = draw_text_input(
    Rect::new(0.0, 0.0, 200.0, 36.0), "hello", 5, None, None,
    false, 0, TextInputStyle::default(), &mut text,
);
assert_eq!(commands.len(), 3); // background, border, glyphs