Struct TextInput

Source
pub struct TextInput {
    pub state: KeyState,
    /* private fields */
}

Fields§

§state: KeyState

Implementations§

Source§

impl TextInput

Source

pub fn new( color: Color, rect: Rect, corner_radius: Option<u32>, text_style: Option<Text>, ) -> Self

Examples found in repository?
examples/basic.rs (lines 72-77)
43fn main() {
44    let mut my_app = MyApp;
45
46    let mut pd_sdl: PgSdl = PgSdl::init("Benday", 1200, 720, Some(60), true, Colors::SKY_BLUE);
47
48    pd_sdl
49        .add_widget(
50            "button",
51            Box::new(Button::new(
52                Colors::ROYAL_BLUE,
53                rect!(500, 500, 200, 100),
54                Some(9),
55                Some(Text::new("Auto !".to_string(), 16, None)),
56            )),
57        )
58        .add_widget(
59            "slider",
60            Box::new(Slider::new(
61                Colors::ROYAL_BLUE,
62                rect!(110, 220, 200, 100),
63                Some(9),
64                SliderType::Continuous {
65                    display: None,
66                    default_value: 0.5,
67                },
68            )),
69        )
70        .add_widget(
71            "text input",
72            Box::new(TextInput::new(
73                Colors::WHITE,
74                rect!(222, 295, 200, 100),
75                Some(9),
76                Some(Text::new("Auto !".to_string(), 16, None)),
77            )),
78        );
79
80    pd_sdl.run(&mut my_app);
81}

Trait Implementations§

Source§

impl Widget for TextInput

Source§

fn update(&mut self, input: &Input, _delta: f32) -> bool

Update the widget based on the inputs
Source§

fn draw(&self, canvas: &mut Canvas<Window>, text_drawer: &mut TextDrawer)

Draw the widget on the canvas

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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Gets the type name of self
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> Downcast for T
where T: AsAny + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
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.