custom button style
#1710
-
Is there an existing issue for this?
Is this issue related to iced?
What happened?Can not set custom style for button. pub struct DefaultButton(pub Palette);
impl button::StyleSheet for DefaultButton {
type Style = button::Appearance;
fn active(&self, style: &Self::Style) -> button::Appearance {
button::Appearance {
text_color: self.0.text,
border_radius: 2.0,
..button::Appearance::default()
}
}
fn hovered(&self, style: &Self::Style) -> button::Appearance {
button::Appearance {
background: Some(Background::Color(Color {
a: 0.25,
..self.0.background
})),
text_color: self.0.text,
..self.active(style)
}
}
fn pressed(&self, style: &Self::Style) -> button::Appearance {
button::Appearance {
shadow_offset: Vector::default(),
..self.active(style)
}
}
fn disabled(&self, style: &Self::Style) -> button::Appearance {
button::Appearance {
text_color: Color {
a: 0.25,
..self.0.text
},
..self.active(style)
}
}
}
button("Home")
.width(Length::Fill)
.style(styles::DefaultButton) // error error:
But it works well with 0.6. What is the expected behavior?Show no errors. Version0.7 Operative SystemmacOS Do you have any log output?no. |
Beta Was this translation helpful? Give feedback.
Answered by
Virgil-N
Feb 21, 2023
Replies: 2 comments 7 replies
-
button("Home")
.width(Length::Fill)
.style(theme::Button::Custom(styles::DefaultButton)) // error
mismatched types
expected struct `std::boxed::Box<(dyn iced::widget::button::StyleSheet<Style = iced::Theme> + 'static)>`
found fn item `fn(Palette) -> DefaultButton {DefaultButton}`
gui.rs(159, 24): arguments to this enum variant are incorrect
theme.rs(139, 5): tuple variant defined here |
Beta Was this translation helpful? Give feedback.
3 replies
-
Does anyone knows how to set custom style for button? |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
Virgil-N
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does anyone knows how to set custom style for button?