examples icon indicating copy to clipboard operation
examples copied to clipboard

Add an Example of Creating a Custom Widget

Open bvinc opened this issue 6 years ago • 4 comments

I would love to see an example of writing a custom widget, for example: A new widget that derives from DrawingArea and implements Scrollable. Information on how to do this seems to be disjointed and hard to find.

bvinc avatar Apr 14 '18 07:04 bvinc

This would be identical to any other trait from a Rust library. Create a new type consisting of a collection of widgets relevant for your type, and implement the two traits for that type.

mmstick avatar Jan 09 '19 21:01 mmstick

Could you clarify what the "two traits" are?

nicholasbishop avatar Sep 20 '19 03:09 nicholasbishop

@mmstick I'm also wondering what the "two traits" are. I've seen WidgetNameExt traits in the existing widgets, but that's only 1 trait, and it's not even the same one for each widget.

john01dav avatar May 19 '20 17:05 john01dav

Here is a blog post about that topic: https://www.figuiere.net/technotes/notes/tn002/ @bvinc maybe this example covers your needs https://gtk-rs.org/docs/src/glib/subclass/types.rs.html#195-224

Gtk-rs examples cover that question, too:

I think the issue can be closed

zzeroo avatar Sep 14 '20 15:09 zzeroo