I’m using the " 0.13.0-dev " branch and trying to follow an example that uses the StyleSheet trait for styling its Button widdgets, but this trait has apparently been removed.
How can I duplicate the behaviour which used to have methods to return a style for “active”, “hovered” etc.?
You put a closure into the style function that produces a Style object. The closure usually takes the current theme and some status of the widget as parameters.
But it is clumsy to wire it up with on_press to pass a message in. How can I create my own version of the Button widget? so I can supply my own methods (along with the supported methods for the default Button) without creating a full-blown custom widget?
That approach is a very common approach. But you would have to apply on_press like with any other button. For me personally, I mostly used it without any issues. But I did it with impl Into<Element<Message>> as parameter types instead of specific widgets. That way, it accepts all kinds of widgets.
Another common approach is to do what @airstrike showed.
Another approach would be to build a custom struct with the data/settings that you need that implements Into<Element<Message>> where you create the actual button. Then you should be able to pass it to widgets like column and row.
Extending the existing button widget, by adding methods to Button like in OOP, is not possible.
Can I get some example as to what you mean by this?
Another approach would be to build a custom struct with the data/settings that you need that implements Into<Element<Message>> where you create the actual button. Then you should be able to pass it to widgets like column and row .
As you can see it takes impl Into<iced::Element<'a, Message>> as parameter. That way I can pass any kind of widget to it. You could do the same for you button function.