Skip to main content

FocusedTextFieldHandler

Trait FocusedTextFieldHandler 

Source
pub trait FocusedTextFieldHandler {
    // Required methods
    fn handle_key(&self, event: &KeyEvent) -> bool;
    fn insert_text(&self, text: &str);
    fn delete_surrounding(&self, before_bytes: usize, after_bytes: usize);
    fn copy_selection(&self) -> Option<String>;
    fn cut_selection(&self) -> Option<String>;
    fn set_composition(&self, text: &str, cursor: Option<(usize, usize)>);
}
Expand description

Handler trait for focused text field operations. Stored in focus module for O(1) key/clipboard dispatch.

Required Methods§

Source

fn handle_key(&self, event: &KeyEvent) -> bool

Handle a key event. Returns true if consumed.

Source

fn insert_text(&self, text: &str)

Insert pasted text.

Source

fn delete_surrounding(&self, before_bytes: usize, after_bytes: usize)

Delete text surrounding the cursor or selection.

Source

fn copy_selection(&self) -> Option<String>

Copy current selection. Returns None if nothing selected.

Source

fn cut_selection(&self) -> Option<String>

Cut current selection (copy + delete). Returns None if nothing selected.

Source

fn set_composition(&self, text: &str, cursor: Option<(usize, usize)>)

Set IME composition (preedit) state.

  • text: The composition text being typed (empty string to clear)
  • cursor: Optional cursor position within composition (start, end)

Implementors§