Skip to main content

TextInput

Struct TextInput 

Source
pub struct TextInput {
Show 21 fields pub text: String, pub font: Option<Font>, pub font_size: f32, pub pos_x: usize, pub pos_y: usize, pub width: usize, pub height: usize, pub bg_col_idle: Color, pub border_col_idle: Color, pub text_col_idle: Color, pub border_size_idle: usize, pub bg_col_editing: Color, pub border_col_editing: Color, pub text_col_editing: Color, pub border_size_editing: usize, pub cursor_col: Color, pub cursor_width: usize, pub radius: usize, pub state: TextInputState, pub cursor_pos: usize, pub scroll_offset: f32, /* private fields */
}

Fields§

§text: String§font: Option<Font>§font_size: f32§pos_x: usize§pos_y: usize§width: usize§height: usize§bg_col_idle: Color§border_col_idle: Color§text_col_idle: Color§border_size_idle: usize§bg_col_editing: Color§border_col_editing: Color§text_col_editing: Color§border_size_editing: usize§cursor_col: Color§cursor_width: usize§radius: usize

Corner radius for rounded edges

§state: TextInputState§cursor_pos: usize§scroll_offset: f32

Implementations§

Source§

impl TextInput

Source

pub fn font(self, font: Font, size: f32) -> Self

Source

pub fn position(self, x: usize, y: usize) -> Self

Source

pub fn size(self, width: usize, height: usize) -> Self

Source

pub fn placeholder(self, text: &str) -> Self

Source

pub fn background(self, color: Color) -> Self

Source

pub fn idle_bg(self, color: Color) -> Self

Source

pub fn editing_bg(self, color: Color) -> Self

Source

pub fn border_color(self, color: Color) -> Self

Source

pub fn idle_border_col(self, color: Color) -> Self

Source

pub fn editing_border_col(self, color: Color) -> Self

Source

pub fn border(self, size: usize) -> Self

Source

pub fn text_color(self, color: Color) -> Self

Source

pub fn idle_text_col(self, color: Color) -> Self

Source

pub fn editing_text_col(self, color: Color) -> Self

Source

pub fn cursor_color(self, color: Color) -> Self

Source

pub fn radius(self, radius: usize) -> Self

Sets the corner radius for rounded edges

Source

pub fn value(&self) -> &str

Returns the current text content

Source

pub fn is_editing(&self) -> bool

Returns whether the input is currently being edited

Source

pub fn draw(&mut self, window: &mut Window)

Draws and updates the text input

Trait Implementations§

Source§

impl Default for TextInput

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