pub struct TextFieldState {
pub text: String,
pub selection: Range<usize>,
pub composition: Option<Range<usize>>,
pub scroll_offset: f32,
pub scroll_offset_y: f32,
pub drag_anchor: Option<usize>,
pub blink_start: Instant,
pub inner_width: f32,
pub inner_height: f32,
pub preferred_x_px: Option<f32>,
}Fields§
§text: String§selection: Range<usize>§composition: Option<Range<usize>>§scroll_offset: f32§scroll_offset_y: f32§drag_anchor: Option<usize>§blink_start: Instant§inner_width: f32§inner_height: f32§preferred_x_px: Option<f32>Implementations§
Source§impl TextFieldState
impl TextFieldState
pub fn new() -> Self
pub fn insert_text(&mut self, text: &str)
pub fn delete_backward(&mut self)
pub fn delete_forward(&mut self)
pub fn move_cursor(&mut self, delta: isize, extend_selection: bool)
pub fn selected_text(&self) -> String
pub fn set_composition(&mut self, text: String, cursor: Option<(usize, usize)>)
pub fn commit_composition(&mut self, text: String)
pub fn cancel_composition(&mut self)
pub fn delete_surrounding(&mut self, before_bytes: usize, after_bytes: usize)
pub fn begin_drag(&mut self, idx_byte: usize, extend: bool)
pub fn drag_to(&mut self, idx_byte: usize)
pub fn end_drag(&mut self)
pub fn caret_index(&self) -> usize
Sourcepub fn ensure_caret_visible(
&mut self,
caret_x_px: f32,
inner_width_px: f32,
inset_px: f32,
)
pub fn ensure_caret_visible( &mut self, caret_x_px: f32, inner_width_px: f32, inset_px: f32, )
Keep caret visible inside inner content width (px).
inset_px is a small padding (px) to avoid hugging edges.
Sourcepub fn ensure_caret_visible_xy(
&mut self,
caret_x_px: f32,
caret_y_px: f32,
inner_w_px: f32,
inner_h_px: f32,
inset_px: f32,
)
pub fn ensure_caret_visible_xy( &mut self, caret_x_px: f32, caret_y_px: f32, inner_w_px: f32, inner_h_px: f32, inset_px: f32, )
Keep caret visible inside an inner rect (for multiline).
pub fn clamp_scroll(&mut self, content_h_px: f32)
pub fn reset_caret_blink(&mut self)
pub fn caret_visible(&self) -> bool
pub fn set_inner_width(&mut self, w_px: f32)
pub fn set_inner_height(&mut self, h_px: f32)
Trait Implementations§
Source§impl Clone for TextFieldState
impl Clone for TextFieldState
Source§fn clone(&self) -> TextFieldState
fn clone(&self) -> TextFieldState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TextFieldState
impl Debug for TextFieldState
Auto Trait Implementations§
impl Freeze for TextFieldState
impl RefUnwindSafe for TextFieldState
impl Send for TextFieldState
impl Sync for TextFieldState
impl Unpin for TextFieldState
impl UnwindSafe for TextFieldState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more