Viewport scrollbarMoved / mouseWheelMoved


i need to synchronize 2 viewport scrolling states (in both way, each one controlling the other).

I found in the process that the scollbarMoved is the perfect way to get the event, but this event is only triggered when the scrollbar is manually moved by dragging or wheeling on the scrollbar.
When wheeling on the viewport, the scrollbar is moved but the scrollbarmoved event is not dispatched, which makes an “incomplete” event flow.

I managed to get all the event using mouseWheel on the parent component, but it’s a bit hacky and not that proper…
I understand that the scrollbar can be used for other purpose and has its own mechanism, but it would great to either trigger the scrollBarMoved callback when the viewport moves the scrollbar by itself, or a separate event dispatched by the viewport “viewportScrolled”, that would be an unique event to notify scrolling in any manner of a viewport.


you could perhaps make a small class that inherits Viewport and that overrides :
virtual void visibleAreaChanged (const Rectangle<int>& newVisibleArea);
and update each other viewport view from there


Thanks !
I’ll check the visibleAreaChanged indeed.
Just out of curiosity, do you know why the scrollbarMoved is not called when wheeling the viewport ?


no, I haven’t checked, but if you are listening to the vertical and horizontal scrollbars, then I expect your listener’s scrollBarMoved() to be called. It’s not the case? not sure why it wouldnt


the scrollbarmoved is not called when using the mouse wheel on the viewport (but it is called when using the mouse wheel on the scrollbar itself).
I guess the viewport handles the wheel event itself and set the scrollbar silently so the scrollbar does not notifies back the viewport…
Anyway, visibleAreaChanged seems to be the one !