Skip to main content

TextFieldState

Struct TextFieldState 

Source
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

Source

pub fn new() -> Self

Source

pub fn insert_text(&mut self, text: &str)

Source

pub fn delete_backward(&mut self)

Source

pub fn delete_forward(&mut self)

Source

pub fn move_cursor(&mut self, delta: isize, extend_selection: bool)

Source

pub fn selected_text(&self) -> String

Source

pub fn set_composition(&mut self, text: String, cursor: Option<(usize, usize)>)

Source

pub fn commit_composition(&mut self, text: String)

Source

pub fn cancel_composition(&mut self)

Source

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

Source

pub fn begin_drag(&mut self, idx_byte: usize, extend: bool)

Source

pub fn drag_to(&mut self, idx_byte: usize)

Source

pub fn end_drag(&mut self)

Source

pub fn caret_index(&self) -> usize

Source

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.

Source

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).

Source

pub fn clamp_scroll(&mut self, content_h_px: f32)

Source

pub fn caret_visible(&self) -> bool

Source

pub fn set_inner_width(&mut self, w_px: f32)

Source

pub fn set_inner_height(&mut self, h_px: f32)

Trait Implementations§

Source§

impl Clone for TextFieldState

Source§

fn clone(&self) -> TextFieldState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextFieldState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TextFieldState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.