pub struct Button<MSG> {
pub text: String,
pub events: Vec<Attribute<Event, MSG>>,
/* private fields */
}
Expand description
Base widget to be used with all upper level ones. It may be used to display a box border around the widget and/or add a text.
§Examples
Button::default()
.text("Button")
.title_style(Style::default().fg(Color::Red))
.borders(Borders::LEFT | Borders::RIGHT)
.border_style(Style::default().fg(Color::White))
.style(Style::default().bg(Color::Black));
Fields§
§text: String
Optional text place on the upper left of the block
events: Vec<Attribute<Event, MSG>>
events attached to this block
Implementations§
Source§impl<MSG> Button<MSG>where
MSG: 'static,
impl<MSG> Button<MSG>where
MSG: 'static,
pub fn new(events: Vec<Attribute<Event, MSG>>, label: &str) -> Self
pub fn label(self, label: &str) -> Self
pub fn area(self, area: Rect) -> Self
pub fn events(self, events: Vec<Attribute<Event, MSG>>) -> Self
pub fn title_style(self, style: Style) -> Self
pub fn border_style(self, style: Style) -> Self
pub fn style(self, style: Style) -> Self
pub fn borders(self, flag: Borders) -> Self
pub fn triggers_event(&self, event: &Event) -> Option<&Callback<Event, MSG>>
Trait Implementations§
Source§impl<MSG> Widget for Button<MSG>where
MSG: 'static,
impl<MSG> Widget for Button<MSG>where
MSG: 'static,
fn get_area(&self) -> Rect
Source§fn draw(&mut self, buf: &mut Buffer)
fn draw(&mut self, buf: &mut Buffer)
Draws the current state of the widget in the given buffer. That the only method required to
implement a custom widget.
Source§fn background(&self, buf: &mut Buffer, color: Color)
fn background(&self, buf: &mut Buffer, color: Color)
Helper method to quickly set the background of all cells inside the specified area.
Source§fn render<B>(&mut self, f: &mut Frame<'_, B>)
fn render<B>(&mut self, f: &mut Frame<'_, B>)
Helper method that can be chained with a widget’s builder methods to render it.
fn top(&self) -> u16
fn bottom(&self) -> u16
fn left(&self) -> u16
fn right(&self) -> u16
Auto Trait Implementations§
impl<MSG> Freeze for Button<MSG>
impl<MSG> !RefUnwindSafe for Button<MSG>
impl<MSG> !Send for Button<MSG>
impl<MSG> !Sync for Button<MSG>
impl<MSG> Unpin for Button<MSG>
impl<MSG> !UnwindSafe for Button<MSG>
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