fix: button styling
This commit is contained in:
parent
dc10c77b41
commit
ffa67981a8
4 changed files with 57 additions and 33 deletions
|
|
@ -55,6 +55,7 @@ pub struct Button<'a, Message> {
|
|||
selected: bool,
|
||||
style: crate::theme::Button,
|
||||
variant: Variant<Message>,
|
||||
force_enabled: bool,
|
||||
}
|
||||
|
||||
impl<'a, Message> Button<'a, Message> {
|
||||
|
|
@ -77,6 +78,7 @@ impl<'a, Message> Button<'a, Message> {
|
|||
selected: false,
|
||||
style: crate::theme::Button::default(),
|
||||
variant: Variant::Normal,
|
||||
force_enabled: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +92,7 @@ impl<'a, Message> Button<'a, Message> {
|
|||
name: None,
|
||||
#[cfg(feature = "a11y")]
|
||||
description: None,
|
||||
force_enabled: false,
|
||||
#[cfg(feature = "a11y")]
|
||||
label: None,
|
||||
content: content.into(),
|
||||
|
|
@ -163,6 +166,12 @@ impl<'a, Message> Button<'a, Message> {
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the the [`Button`] to enabled whether or not it has handlers for on press.
|
||||
pub fn force_enabled(mut self, enabled: bool) -> Self {
|
||||
self.force_enabled = enabled;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the widget to a selected state.
|
||||
///
|
||||
/// Displays a selection indicator on image buttons.
|
||||
|
|
@ -348,7 +357,8 @@ impl<'a, Message: 'a + Clone> Widget<Message, crate::Theme, crate::Renderer>
|
|||
|
||||
let mut headerbar_alpha = None;
|
||||
|
||||
let is_enabled = self.on_press.is_some() || self.on_press_down.is_some();
|
||||
let is_enabled =
|
||||
self.on_press.is_some() || self.on_press_down.is_some() || self.force_enabled;
|
||||
let is_mouse_over = cursor.position().is_some_and(|p| bounds.contains(p));
|
||||
|
||||
let state = tree.state.downcast_ref::<State>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue