Skip to content

[Feature] Text input widget #154

@vmarcella

Description

@vmarcella

Overview

Add a text input widget for single-line text entry with cursor and selection.

Current State

No response

Scope

Goals:

  • Single-line text entry
  • Cursor positioning with click
  • Keyboard input handling
  • Text selection (shift+arrow)
  • Copy/paste support

Non-Goals:

  • Multi-line text area
  • Rich text editing
  • Input validation

Proposed API

pub struct TextInput {
  text: String,
  cursor_position: usize,
  selection_start: Option<usize>,
  placeholder: Option<String>,
  on_change: Option<Box<dyn Fn(&str)>>,
  on_submit: Option<Box<dyn Fn(&str)>>,
}

impl TextInput {
  pub fn new() -> Self;
  pub fn with_placeholder(self, text: &str) -> Self;
  pub fn on_change(self, callback: impl Fn(&str) + 'static) -> Self;
  pub fn on_submit(self, callback: impl Fn(&str) + 'static) -> Self;
  pub fn text(&self) -> &str;
  pub fn set_text(&mut self, text: &str);
  pub fn clear(&mut self);
}

impl Widget for TextInput {
  fn render(&self, ctx: &mut UiRenderContext) -> Vec<RenderCommand>;
}

Acceptance Criteria

  • Text entry works with keyboard
  • Cursor visible and blinking
  • Click positions cursor
  • Arrow keys move cursor
  • Selection with shift+arrows
  • Enter key triggers submit
  • Placeholder shows when empty

Affected Crates

lambda-rs

Notes

  • Handle Ctrl+A (select all), Ctrl+C/V (copy/paste)
  • Clipboard requires platform integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    UIAll things user interface relatedenhancementNew feature or requestlambda-rsIssues pertaining to the core framework

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions