Gtk custom widget doesn't scroll

I made a custom widget by subclassing GtkLayout. From the documentation I read this widget has native scrolling abilities so it doesn’t need a Gtkviewport. The problem is my custom widget doesn’t scroll when I use the mouse wheel on it. I guess it’s an allocation problem but what shall I modify to have it to scroll? The widget extends itself up to 00:04:59.

This is the widget.h:

This is the draw function:

And this is the scroll function:

Thank you so much in advance :slight_smile:

If anyone wants to help here is the github project page: GitHub - colossus73/gtk_timeline: A GTK3 custom widget aiming to create an intuitive, customizable timeline widget. I started this project to give my 11 years still slowly developed software, Imagination, a decent and modern timeline.

That is correct, but a bit misleading.

There are two parts of scrolling:

  1. the ability of a widget to show a partial viewport, determined by horizontal and vertical adjustments
  2. a widget to control scrolling, like adding scrollbars as necessary, and processing input events like mouse wheel scrolls to adjust the scroll position

GtkViewport is a generic implementation for 1., and some widget have native support for scrolling.

But you still need a second widget that does 2., usually GtkScrolledWindow.

1 Like

Thank you so much indeed for replying. I added the viewport and I get now the scrollbars but the mouse wheel doesn’t scroll the custom widget.

Am I supposed to use gtk_adjustment_set_value() to move the scrollbars am I not?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.