How to track vertical and horizontal scroll event in ScrolledWindow

I have three DrawingArea’s inside their own respective ViewPort and ScrolledWindow as shown the image below

How can I detect horizontal or/and vertical scroll in any one of the scrolled window?
After detecting the horizontal or/and vertical scroll in any one of the scrolled window adjust the other two scrolled window horizontal or/and vertical same?

I found this Catching the scrolling event in gtk# post which suggests to use Chapter 14. Adjustments

Suggested to use of attaching adjustment to scroll bar and find change in the value of the scroll bar.


    builder->get_widget("scrollWindow1", scrollWindow1);
    scrollWindow1->set_hadjustment(Gtk::Adjustment::create(0,0,0, 0.5));
    scrollWindow1->set_vadjustment(Gtk::Adjustment::create(0,0,0, 0.5));

    builder->get_widget("viewPort1", viewPort1);

    Gtk::ScrolledWindow* scrollWindow1;
    Gtk::DrawingArea drawingArea1;

    Glib::RefPtr<Gtk::Adjustment> vAdjustment;
    vAdjustment = viewModelScrollWindow1->get_vadjustment();

    Gtk::Scrollbar vscrbr;

    vscrbr (*vAdjustment,Gtk::ORIENTATION_VERTICAL);

void myClass::printVvalue()
    std::cout<<"V value: "<<vscrbr.get_value()<<std::endl;

I get this error

error: no match for call to ??(Gtk::Scrollbar) (Glib::RefPtrGtk::Adjustment&, Gtk::Orientation)??
vscrbr (vAdjustment,Gtk::ORIENTATION_VERTICAL);

What am I doing wrong?

How can I do it correctly?

I can’t help you with anything gtkmm specific, but unless I misunderstand what you want to achieve, you can share the same two adjustments (vertical and horizontal) between the three scrolled windows to keep the scroll positions in sync without any bindings/signals.

Yes, that’s the idea.

Gtk::Scrollbar vscrbr;
vscrbr (*vAdjustment,Gtk::ORIENTATION_VERTICAL);

What are you trying to do here? To call the Scrollbar constructor with 2 parameters:

Gtk::Scrollbar vscrbr(vAdjustment,Gtk::ORIENTATION_VERTICAL);

or call the default constructor and then some set methods:

Gtk::Scrollbar vscrbr;

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