pub struct InputBox {
pub input: String,
pub placeholder: String,
pub x: u16,
pub y: u16,
}Expand description
A structure representing an input box that allows the user to enter text.
Fields§
§input: String§placeholder: String§x: u16§y: u16Implementations§
Source§impl InputBox
impl InputBox
Sourcepub fn new(input: &str, placeholder: &str, x: u16, y: u16) -> Self
pub fn new(input: &str, placeholder: &str, x: u16, y: u16) -> Self
Creates a new InputBox instance.
§Arguments
input- A string slice that holds the initial text of the input box.placeholder- A string slice that holds the placeholder text to display.x- The horizontal position (x-coordinate) where the input box will be drawn.y- The vertical position (y-coordinate) where the input box will be drawn.
§Returns
A new instance of InputBox.
Sourcepub fn get_input(&mut self) -> Result<String>
pub fn get_input(&mut self) -> Result<String>
Retrieves input from the user and updates the input box.
This function displays the input box at the specified position and handles user input, including entering characters and using the backspace key.
§Returns
An io::Result<String> that contains the input entered by the user or an error if
the read operation fails.
§Example
let mut input_box = InputBox::new("", "Enter text here", 5, 10);
let user_input = input_box.get_input().unwrap(); // Gets user inputAuto Trait Implementations§
impl Freeze for InputBox
impl RefUnwindSafe for InputBox
impl Send for InputBox
impl Sync for InputBox
impl Unpin for InputBox
impl UnsafeUnpin for InputBox
impl UnwindSafe for InputBox
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