pub struct Button {
pub text: String,
pub area: Option<Rect>,
pub hovered: bool,
pub normal_style: Style,
pub hover_style: Style,
}Expand description
A clickable button widget for the UI
Fields§
§text: StringThe text displayed on the button
area: Option<Rect>The area where the button is rendered (for click detection)
hovered: boolWhether the button is currently hovered
normal_style: StyleNormal style (not hovered)
hover_style: StyleHover style
Implementations§
Source§impl Button
impl Button
Sourcepub fn normal_style(self, style: Style) -> Self
pub fn normal_style(self, style: Style) -> Self
Set custom normal style
Sourcepub fn hover_style(self, style: Style) -> Self
pub fn hover_style(self, style: Style) -> Self
Set custom hover style
Sourcepub fn is_clicked(&self, column: u16, row: u16) -> bool
pub fn is_clicked(&self, column: u16, row: u16) -> bool
Check if a mouse click at (column, row) is within the button area
Sourcepub fn update_hover(&mut self, column: u16, row: u16)
pub fn update_hover(&mut self, column: u16, row: u16)
Update hover state based on mouse position
Sourcepub fn render(
&self,
panel_area: Rect,
_title_prefix: &str,
) -> (Span<'static>, Rect)
pub fn render( &self, panel_area: Rect, _title_prefix: &str, ) -> (Span<'static>, Rect)
Render the button as a styled span (owned version for use in Line::from) Returns (Span, area) where area is the calculated button position
Sourcepub fn render_with_title(
&mut self,
panel_area: Rect,
title: &str,
) -> Line<'static>
pub fn render_with_title( &mut self, panel_area: Rect, title: &str, ) -> Line<'static>
Create a complete title line with the button on the right Also updates the button’s area for click detection Returns a Line with ’static lifetime since it owns all its data
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Button
impl RefUnwindSafe for Button
impl Send for Button
impl Sync for Button
impl Unpin for Button
impl UnwindSafe for Button
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more