I am doing a project in Vala
which Gtk+
I need to allow me to add a scrollbar that contains a box or if it is not possible with a Layout or Fixed, precisely a vertical scrollbar. I'm having trouble adding it to my project because I can't find the way to do it anywhere, there are only examples using ScrolledWindow
it, which isn't exactly what I'm looking for, but rather one that can be used in a Widget instead of the window, as I mentioned before. I show you a part of the code programmed in Vala:
Box caja = new Box(Orientation.VERTICAL, 0);//Widget que quiero que se pueda controlar con un scroll
Label label = new Label("Esto es una etiqueta");
caja.pack_start(label, false, false, 0);
... //Agrego dentro de "caja" mas elementos, para que se llene.
caja.show_all();
Here is an example using ScrolledWindow
:
Gtk.ScrolledWindow scrolled = new Gtk.ScrolledWindow (null, null);
this.add (scrolled);
scrolled.add(caja);
But it doesn't do anything, it doesn't even show the Scroll. Any way to fix this, you would do me a great favor.
use a
Gtk.Viewport
inside aGtk.ScrolledWindow
and then add your containerGtk.Box
to be able to use the scroll inside the Widget (an example):You can be guided by the documentation of the valadoc on
Gtk.Viewport
.