Struct intuitive::components::experimental::input::Input
source · pub struct Input {
pub title: Spans,
pub border: Style,
pub on_key: KeyHandler,
pub on_mouse: MouseHandler,
}
Available on crate feature
experimental
only.Expand description
A single-line input component with cursor controls.
This is a smart input box with the following features:
- rendering a cursor
- scrolling on overflow
- supports navigating with arrow keys
- supports navigating with
ctrl+a
andctrl+e
- has a fixed single-line height of 3 rows
Vertical Alignment
Since this component always renders as three blocks high,
when more space is available it vertically centers itself.
In order to align this element to the top, you will need
to use VStack
along with Flex::Block
and properly
route the key events:
#[component(Root)]
fn render() {
let input: element::Any = render! {
Input(title: "Input Box")
};
let on_key = on_key! { [input]
KeyEvent { code: Esc, .. } => event::quit(),
event => input.on_key(event),
};
render! {
VStack(flex: [Block(3), Grow(1)], on_key) {
Embed(content: input)
Empty()
}
}
}
Fields§
§title: Spans
§border: Style
§on_key: KeyHandler
§on_mouse: MouseHandler
Implementations§
source§impl Input
impl Input
pub fn new( title: Spans, border: Style, on_key: KeyHandler, on_mouse: MouseHandler ) -> Any
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Input
impl Send for Input
impl Sync for Input
impl Unpin for Input
impl !UnwindSafe for Input
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